Changeset 15 for trunk/threads-peterson.c
- Timestamp:
- Apr 21, 2012, 12:24:25 PM (14 years ago)
- File:
- 
      - 1 edited
 
 - 
          
  trunk/threads-peterson.c (modified) (4 diffs)
 
Legend:
- Unmodified
- Added
- Removed
- 
      trunk/threads-peterson.cr2 r15 26 26 int run(const int p, void* s) 27 27 { 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) { 31 30 sleep(1); 32 31 printf("Processo figlio (%d). s = %d\n", … … 37 36 } 38 37 shared[0] += 1; 39 leave_section(p, &shared[2]); 38 leave_section(p, &shared[2]); 40 39 } 40 leave_section(p, &shared[2]);// il test nel while \`e dopo enter\_section 41 41 42 return 0; 42 43 } … … 61 62 malloc(4096)+4096, /* lo stack del nuovo processo 62 63 * (cresce verso il basso!) */ 63 CLONE_VM | SIGCHLD, /* la (virtual) memory e`condivisa */64 CLONE_VM | SIGCHLD, /* la (virtual) memory \`e condivisa */ 64 65 shared) < 0){ 65 66 perror("Errore nella creazione"); … … 73 74 74 75 /* Memoria condivisa: i due figli nell'insieme eseguono 10 o 75 * 11 volte : e` possibile una corsa critica. Il padre76 * 11 volte con possibili corse critiche. Il padre 76 77 * condivide shared[0] con i figli */ 77 78 
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  
