* problem with shared memory under Win9x
@ 2000-01-25 3:07 Pakoulin Konstantin
0 siblings, 0 replies; 2+ messages in thread
From: Pakoulin Konstantin @ 2000-01-25 3:07 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* problem with shared memory under Win9x
@ 2000-01-26 3:28 Pakoulin Konstantin
0 siblings, 0 replies; 2+ messages in thread
From: Pakoulin Konstantin @ 2000-01-26 3:28 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-01-26 3:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-25 3:07 problem with shared memory under Win9x Pakoulin Konstantin
2000-01-26 3:28 Pakoulin Konstantin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).