This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: mmap not share


On Mon, Jun 25, 2001 at 08:48:59PM +0200, Dirk Freyer wrote:
> Under Linux this file works fine. Two tasks increments one counter :-)
> With Windows 98 i have the problem that the two tasks increments two counters :-(
> 
> Why ???
> 
> I use cygwin 1.8.2
> 
>   int fd;
>   void *ptr=NULL;
>   int *counter;
>  
>   if ( (fd=open("tmem.sm",O_RDWR)) == -1) printf("File Error\n");
>   else 
>   if((ptr = mmap (NULL,sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == -1)
>         printf("mmap Error\n");
>   close(fd);
>   printf("File=%i Ptr=%i\n",fd,ptr);
>   counter=ptr;
>   while (TRUE) {
>       printf("counter=%i\n",(*counter)++);
> 	...
>   }

Ok, I just had an extensive test on this. It happens only on
9x/ME, not on NT/W2K. For some reason the Win32 API call MapViewOfFile()
doesn't return the same address in both processes as it's described
in MSDN. The mapped objects have no clue of each other. Even synching
using the FlushViewOfFile() function inside of msync() doesn't show
an effect since the other process happily overrides that the next time.

I have an idea to implement sth. especially for 9x/ME since I suspect
a special undocumented behaviour. Don't know if that will work but if so,
I will apply that to Cygwin and keep the list informed.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]