This is the mail archive of the cygwin@sourceware.cygnus.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]

problem with shared memory under Win9x


Hello,
I use shared memory for IPC in my programm, but it doesnt work under
Win9x. I writed test programm that works well under WinNT but doesnt
work under Win9x:

#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


#define FILENAME "test.bin"
#define FILE_MODE       (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)

int main() {

        if ( fork()!=0 ) {

                // Parent - server
                
                int fd;
                int* mem;
                int z = 0;
        
                fd  = open( FILENAME , O_RDWR | O_CREAT , FILE_MODE );
                write( fd, &z, sizeof(int) );

                mem = mmap( NULL, sizeof(int) , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        
                close(fd);

                printf("par: Waiting!!\n");

                while(!(*mem)) ;

                // 'mem' equal 0 constantly under Win9x
                
                printf("par: !!!Works Well!!! - %d \n", *mem);

                exit(0);

        } else {

                // Child - client

                int fd;
                int* mem;

                sleep(3);

                fd  = open( FILENAME , O_RDWR | O_CREAT , FILE_MODE );

                mem = mmap( NULL, sizeof(int) , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        
                close(fd);

                printf("ch: MEM = 3 !!\n");

                *mem = 3;

                exit(0);
        };
}

Do you have any idea ?



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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