Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Tue, 10 Jul 2001 19:47:13 +0200 From: Corinna Vinschen To: cygwin Subject: Re: mmap not share Message-ID: <20010710194713.W8578@cygbert.vinschen.de> Mail-Followup-To: cygwin References: <01C0FDB8 DOT 43518680 DOT dfreyer AT telecom DOT insa-lyon DOT fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <01C0FDB8.43518680.dfreyer@telecom.insa-lyon.fr>; from dfreyer@telecom.insa-lyon.fr on Mon, Jun 25, 2001 at 08:48:59PM +0200 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 AT cygwin DOT 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/