#include #include #include #include #include #include /* mnemonici in mode */ #include /* mnemonici in oflag */ #include //syncro7.c int main (void) { int fd,i, pid,size=sizeof(float); float* shared_memory; float* p; float* q; sem_t * sem1_id; sem_t * sem2_id; fd = shm_open("mymem", O_CREAT | O_EXCL |O_RDWR, S_IRUSR | S_IWUSR); ftruncate(fd,size); 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); sem_wait(sem2_id); q=shared_memory; for(i=0;i<10;i++) {printf("sshh2. *q=%f\n", (*q)++);} }