#include #include #include #include #include #include /* mnemonici in mode */ #include /* mnemonici in oflag */ #include //syncro8.c da usare con syncro7.c int main (void){ int fd,i, pid,size=5*sizeof(float); float* shared_memory; float* p; float* q; sem_t * sem1_id; sem_t * sem2_id; fd = shm_open("mymem", O_EXCL |O_RDWR, S_IRUSR | S_IWUSR); shared_memory = mmap(NULL ,size,PROT_READ | PROT_WRITE, MAP_SHARED ,fd, 0); sem1_id = sem_open("/mysem1", O_CREAT, S_IRUSR | S_IWUSR, 1); sem2_id = sem_open("/mysem2", O_CREAT, S_IRUSR | S_IWUSR, 0); p=shared_memory; sem_post(sem2_id); for(i=0; i<10; i++) printf ("\tsshh1 *p = %f\n", (*p)++); shm_unlink("mymem"); }