#include #include #include #include #include #include /* mnemonici in mode */ #include /* mnemonici in oflag */ #include #define BUF_SIZE 5 void main (int argc, char **argv) { int fd, i, j, pid, size=(BUF_SIZE+1)*sizeof(float); float* buffer; sem_t* mutex3; sem_t* db; int* nr_lett; float value, elto=0; time_t t; srand((unsigned) time(&t)); mutex3=sem_open("mutex3", O_CREAT, S_IRUSR | S_IWUSR, 1); /* creo i semafori */ db=sem_open("db", O_CREAT, S_IRUSR | S_IWUSR, 1); fd = shm_open("mymem3", O_CREAT | O_EXCL |O_RDWR, S_IRUSR | S_IWUSR); /* creo la SHM */ ftruncate(fd,size); buffer = mmap(NULL ,size,PROT_READ | PROT_WRITE, MAP_SHARED ,fd, 0); nr_lett=(int*)(buffer+BUF_SIZE); *nr_lett=0; for(i=0;i