#include #include #include #include #include #include /* mnemonici in mode */ #include /* mnemonici in oflag */ #include //syncro10.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++){ sem_wait(sem1_id); printf("\tB *p = %f\n", (*p)++); sem_post(sem1_id); } shm_unlink("mymem"); }