#include #include #include #include #include #include #include #include #include #define SIZE 10 //syncro1.c int main(int argc, char **argv) { int fd, i, val, pid,*ptr; sem_t mutex; ptr = mmap(0, sizeof(int)*SIZE, PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_SHARED, -1, 0); pid=fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { val=(*ptr)++;printf("figlio: %d\n", val); } exit(0); } else{ for (i = 0; i < SIZE; i++) { val=(*ptr)++; printf("padre: %d\n", val); } exit(0); } }