Ignore:
Timestamp:
Apr 21, 2012, 12:24:25 PM (12 years ago)
Author:
Mattia Monga
Message:

Aggiornati 2012

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/threads-peterson.c

    r2 r15  
    2626int run(const int p, void* s)
    2727{
    28         int* shared = (int*)s; /* alias per comodita` */
    29         while (enter_section(p, &shared[1], &shared[2]),
    30                shared[0] < 10) {
     28        int* shared = (int*)s; // alias per comodit\`a
     29        while (enter_section(p, &shared[1], &shared[2]), shared[0] < 10) {
    3130                sleep(1);
    3231                printf("Processo figlio (%d). s = %d\n",
     
    3736                }
    3837                shared[0] += 1;
    39                 leave_section(p, &shared[2]);
     38                leave_section(p, &shared[2]); 
    4039        }
     40        leave_section(p, &shared[2]);// il test nel while \`e dopo enter\_section
     41
    4142        return 0;
    4243}
     
    6162                  malloc(4096)+4096,  /* lo stack del nuovo processo
    6263                                       *  (cresce verso il basso!) */
    63                   CLONE_VM | SIGCHLD, /* la (virtual) memory e` condivisa */
     64                  CLONE_VM | SIGCHLD, /* la (virtual) memory \`e condivisa */
    6465                  shared) < 0){
    6566                perror("Errore nella creazione");
     
    7374
    7475        /* Memoria condivisa: i due figli nell'insieme eseguono 10 o
    75          * 11 volte: e` possibile una corsa critica. Il padre
     76         * 11 volte con possibili corse critiche. Il padre
    7677         * condivide shared[0] con i figli */
    7778
Note: See TracChangeset for help on using the changeset viewer.