Index: trunk/Makefile
===================================================================
--- trunk/Makefile	(revision 11)
+++ trunk/Makefile	(revision 15)
@@ -1,31 +1,33 @@
-CFLAGS=-m32
-LDFLAGS=-m32
+TARGET_ARCH=-m32
+ASM=nasm
 
 mioboot: mioboot.asm
-	nasm -l $@.lst -o $@ $<
+	$(ASM) -l $@.lst -o $@ $<
 
 mioboot-nobios: mioboot-nobios.asm
-	nasm -l $@.lst -o $@ $<
+	$(ASM) -l $@.lst -o $@ $<
 
 mioboot-nobios-simple: mioboot-nobios-simple.asm
-	nasm -l $@.lst -o $@ $<
+	$(ASM) -l $@.lst -o $@ $<
 
 
-esercizio: esercizio.asm
-	nasm -f elf $<
-	gcc -o $@ esercizio.o
+esercizio.o: esercizio.asm
+	$(ASM) -felf $<
+
+esercizio: esercizio.o
+
+pthreads-pc : LDFLAGS=-lrt
 
 pthreads-pc: pthreads-pc.c
-	cc -pthread pthreads-pc.c -o pthreads-pc
 
 fork-pc: fork-pc.c
-	cc fork-pc.c -o fork-pc
 
-tsl: tsl.asm
-	nasm -felf tsl.asm
-	gcc tsl.o -o tsl
+tsl.o: tsl.asm
+	$(ASM) -felf tsl.asm
+
+tsl: tsl.o
 
 enter.o: enter.asm
-	nasm -felf enter.asm
+	$(ASM) -felf enter.asm
 
 threads-tsl: threads-tsl.o enter.o
Index: trunk/threads-isolated.c
===================================================================
--- trunk/threads-isolated.c	(revision 11)
+++ trunk/threads-isolated.c	(revision 15)
@@ -10,5 +10,5 @@
 int run(void* s)
 {
-        int* shared = (int*)s; /* alias per comodita` */
+        int* shared = (int*)s; // alias per comodit\`a
         while (shared[0] < 10) {
                 sleep(1);
@@ -28,5 +28,4 @@
  
         int shared[2] = {0 , 0};
-
         /* int clone(int (*fn)(void *), 
          *           void *child_stack, 
@@ -40,19 +39,16 @@
                   malloc(4096)+4096,  /* lo stack del nuovo processo 
                                        *  (cresce verso il basso!) */
-                  SIGCHLD, /* in questo caso la clone e` analoga alla fork */
+                  SIGCHLD, // in questo caso la clone \`e analoga alla fork 
                   shared) < 0){
-                perror("Errore nella creazione");
-                exit(1);
+                perror("Errore nella creazione");exit(1);
+        } 
+        if (clone(run, malloc(4096)+4096,  SIGCHLD, shared) < 0){
+                perror("Errore nella creazione");exit(1);
         } 
 
-        if (clone(run, malloc(4096)+4096,  SIGCHLD, shared) < 0){
-                perror("Errore nella creazione");
-                exit(1);
-        } 
+        /* Isolati: ciascuno dei figli esegue 10 volte. */
+        // Per il padre shared[0] \`e \textbf{sempre} 0 */
 
-        /* Isolati: ciascuno dei figli esegue 10 volte. Per il padre
-         * shared[0] e` sempre 0 */
-
-        while(1) {
+        while(shared[0] == 0) {
                 sleep(1);
                 printf("Processo padre. s = %d\n", shared[0]);
Index: trunk/threads-peterson.c
===================================================================
--- trunk/threads-peterson.c	(revision 11)
+++ trunk/threads-peterson.c	(revision 15)
@@ -26,7 +26,6 @@
 int run(const int p, void* s)
 {
-        int* shared = (int*)s; /* alias per comodita` */
-        while (enter_section(p, &shared[1], &shared[2]), 
-               shared[0] < 10) {
+        int* shared = (int*)s; // alias per comodit\`a 
+        while (enter_section(p, &shared[1], &shared[2]), shared[0] < 10) {
                 sleep(1);
                 printf("Processo figlio (%d). s = %d\n", 
@@ -37,6 +36,8 @@
                 }
                 shared[0] += 1;
-                leave_section(p, &shared[2]);
+                leave_section(p, &shared[2]); 
         }
+        leave_section(p, &shared[2]);// il test nel while \`e dopo enter\_section
+
         return 0;
 }
@@ -61,5 +62,5 @@
                   malloc(4096)+4096,  /* lo stack del nuovo processo 
                                        *  (cresce verso il basso!) */
-                  CLONE_VM | SIGCHLD, /* la (virtual) memory e` condivisa */
+                  CLONE_VM | SIGCHLD, /* la (virtual) memory \`e condivisa */
                   shared) < 0){
                 perror("Errore nella creazione");
@@ -73,5 +74,5 @@
 
         /* Memoria condivisa: i due figli nell'insieme eseguono 10 o
-         * 11 volte: e` possibile una corsa critica. Il padre
+         * 11 volte con possibili corse critiche. Il padre
          * condivide shared[0] con i figli */
 
Index: trunk/threads-shared.c
===================================================================
--- trunk/threads-shared.c	(revision 11)
+++ trunk/threads-shared.c	(revision 15)
@@ -10,5 +10,5 @@
 int run(void* s)
 {
-        int* shared = (int*)s; /* alias per comodita` */
+        int* shared = (int*)s; // alias per comodit\`a 
         while (shared[0] < 10) {
                 sleep(1);
@@ -28,5 +28,4 @@
  
         int shared[2] = {0 , 0};
-
         /* int clone(int (*fn)(void *), 
          *           void *child_stack, 
@@ -40,20 +39,18 @@
                   malloc(4096)+4096,  /* lo stack del nuovo processo 
                                        *  (cresce verso il basso!) */
-                  CLONE_VM | SIGCHLD, /* la (virtual) memory e` condivisa */
+                  CLONE_VM | SIGCHLD, // (virtual) memory condivisa
                   shared) < 0){
-                perror("Errore nella creazione");
-                exit(1);
+                perror("Errore nella creazione");exit(1);
         } 
 
         if (clone(run, malloc(4096)+4096,  CLONE_VM | SIGCHLD, shared) < 0){
-                perror("Errore nella creazione");
-                exit(1);
+                perror("Errore nella creazione");exit(1);
         } 
 
         /* Memoria condivisa: i due figli nell'insieme eseguono 10 o
-         * 11 volte: e` possibile una corsa critica. Il padre
+         * 11 volte: \`e possibile una corsa critica. Il padre
          * condivide shared[0] con i figli */
 
-        while(1) {
+        while(shared[0] < 10) {
                 sleep(1);
                 printf("Processo padre. s = %d\n", shared[0]);
Index: trunk/threads-tsl.c
===================================================================
--- trunk/threads-tsl.c	(revision 11)
+++ trunk/threads-tsl.c	(revision 15)
@@ -10,15 +10,10 @@
 
 void enter_section(int *s); /* in enter.asm */
+void leave_section(int *s){ *s = 0; }
 
-void leave_section(int *s){
-        *s = 0;
-}
-
-int run(const int p, void* s)
-{
-        int* shared = (int*)s; /* alias per comodita` */
-        while (enter_section(&shared[1]), 
-               shared[0] < 10) {
-                sleep(100);
+int run(const int p, void* s){
+        int* shared = (int*)s; // alias per comodit\`a 
+        while (enter_section(&shared[1]), shared[0] < 10) {
+                sleep(1);
                 printf("Processo figlio (%d). s = %d\n", 
                        getpid(), shared[0]);
@@ -31,4 +26,5 @@
                 sched_yield();
         }
+        leave_section(&shared[1]); // il test nel while \`e dopo enter\_section
         return 0;
 }
@@ -53,5 +49,5 @@
                   malloc(4096)+4096,  /* lo stack del nuovo processo 
                                        *  (cresce verso il basso!) */
-                  CLONE_VM | SIGCHLD, /* la (virtual) memory e` condivisa */
+                  CLONE_VM | SIGCHLD, /* la (virtual) memory \`e condivisa */
                   shared) < 0){
                 perror("Errore nella creazione");
@@ -65,5 +61,5 @@
 
         /* Memoria condivisa: i due figli nell'insieme eseguono 10 o
-         * 11 volte: e` possibile una corsa critica. Il padre
+         * 11 volte: \`e possibile una corsa critica. Il padre
          * condivide shared[0] con i figli */
 
Index: trunk/tsl.asm
===================================================================
--- trunk/tsl.asm	(revision 11)
+++ trunk/tsl.asm	(revision 15)
@@ -7,5 +7,5 @@
 	call stampa
 	lock bts dword [x], 0
-	jc salta  		; gia` settato
+	jc salta  		; gi\`a settato
 	call stampa
 salta:	lock bts dword [x], 0
