Index: /trunk/Makefile
===================================================================
--- /trunk/Makefile	(revision 25)
+++ /trunk/Makefile	(revision 26)
@@ -1,4 +1,5 @@
 TARGET_ARCH=-m32
 ASM=nasm
+CFLAGS=-masm=intel -Wall
 
 mioboot: mioboot.asm
@@ -17,5 +18,5 @@
 esercizio: esercizio.o
 
-pthreads-pc : LDFLAGS=-lrt
+pthreads-pc rw rw-nosync rw-mutex rw-rlotto: LDFLAGS=-lpthread
 
 pthreads-pc: pthreads-pc.c
@@ -33,4 +34,14 @@
 threads-tsl: threads-tsl.o enter.o
 
+threads-tsl-new: threads-tsl-new.c
+
+%.tex : %.nw
+	noweave -delay -filter btdefn -index -filter "awk -f lst.awk|tee debug" $< > $@
+
+%.c : %.nw
+	notangle -R$@ -filter btdefn $< > $@
+
+%.pdf : %.tex
+	pdflatex $< && pdflatex $< && pdflatex $<
 
 .PHONY: clean
Index: /trunk/enter.asm
===================================================================
--- /trunk/enter.asm	(revision 25)
+++ /trunk/enter.asm	(revision 26)
@@ -6,4 +6,8 @@
         mov   ebx,[ebp+8]     ; first parameter to function
 
+
+;; bts bitbase bitoffset
+;; selects the bitoffset bit in bitbase,
+;; stores the value in the CF flag, and sets the bit to 1
 spin:   lock bts dword [ebx], 0
         jc spin
Index: /trunk/enter2.asm
===================================================================
--- /trunk/enter2.asm	(revision 25)
+++ /trunk/enter2.asm	(revision 26)
@@ -8,16 +8,9 @@
 	
 	
-spin:   mov ecx, 0
+spin:	push busy
+	call printf
 	lock bts dword [ebx], 0
-	jc save
-print:  push busy
-	call printf
+	jc spin
 
-	cmp ecx, 1
-        je spin
-
-save:	mov ecx, 1
-	jmp print
-	
         leave                   ; mov esp,ebp / pop ebp
         ret     
Index: /trunk/filefigli.c
===================================================================
--- /trunk/filefigli.c	(revision 25)
+++ /trunk/filefigli.c	(revision 26)
@@ -34,5 +34,5 @@
         }
         lsofd("padre (senza figli)");
-        if (write(f, string, (strlen(string)+1)) != (strlen(string)+1) ){
+        if (write(f, string, (strlen(string))) != (strlen(string)) ){
                 perror("write");
                 exit(1);
Index: /trunk/forca.c
===================================================================
--- /trunk/forca.c	(revision 25)
+++ /trunk/forca.c	(revision 26)
@@ -6,17 +6,13 @@
   int x = fork();
   if (x < 0){
-      perror("Errore nella fork:");
-      exit(1);
-  } else {
-    if (x != 0){
-      while(1) printf("Processo padre (Figlio: %d)\n", x);
-    } else {
-      while(1) printf("Processo figlio (%d)\n", x);
-    }
+    perror("Errore nella fork:");
+    exit(1);
+  }
+  if (x != 0){
+    while(1) printf("Processo padre (x == %d)\n", x);
+  }  
+  else { // x == 0
+   while(1) printf("Processo figlio (x == %d)\n", x);        
   }
   return 0;
 }
-
-    
-        
-  
Index: /trunk/hello.c
===================================================================
--- /trunk/hello.c	(revision 25)
+++ /trunk/hello.c	(revision 26)
@@ -1,12 +1,14 @@
+/* Copyright (C) 2014 by Mattia Monga <mattia.monga@unimi.it> */
+/* $Id$ */
+
 #include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
 
-int main(void){
-  int i;
-  for (i=0; i<10; i++){
-    printf("Hello world! (%d)\n", i+1);
-    sleep(1);
-  }
-  exit(0);
+int main(){
+    printf("Ciao %d %s", 5, "mamma");
+    asm("mov eax, 0");
+    return 0;
 }
+
+/* Local Variables: */
+/* compile-command: "make -k " */
+/* End: */
Index: /trunk/hello.s
===================================================================
--- /trunk/hello.s	(revision 25)
+++ /trunk/hello.s	(revision 26)
@@ -1,6 +1,9 @@
 	.file	"hello.c"
+	.intel_syntax noprefix
 	.section	.rodata
 .LC0:
-	.string	"Hello world! (%d)\n"
+	.string	"mamma"
+.LC1:
+	.string	"Ciao %d %s"
 	.text
 	.globl	main
@@ -9,30 +12,28 @@
 .LFB0:
 	.cfi_startproc
-	pushl	%ebp
+	push	ebp
 	.cfi_def_cfa_offset 8
 	.cfi_offset 5, -8
-	movl	%esp, %ebp
+	mov	ebp, esp
 	.cfi_def_cfa_register 5
-	andl	$-16, %esp
-	subl	$32, %esp
-	movl	$0, 28(%esp)
-	jmp	.L2
-.L3:
-	movl	28(%esp), %eax
-	addl	$1, %eax
-	movl	%eax, 4(%esp)
-	movl	$.LC0, (%esp)
+	and	esp, -16
+	sub	esp, 16
+	mov	DWORD PTR [esp+8], OFFSET FLAT:.LC0
+	mov	DWORD PTR [esp+4], 5
+	mov	DWORD PTR [esp], OFFSET FLAT:.LC1
 	call	printf
-	movl	$1, (%esp)
-	call	sleep
-	addl	$1, 28(%esp)
-.L2:
-	cmpl	$9, 28(%esp)
-	jle	.L3
-	movl	$0, (%esp)
-	call	exit
+#APP
+# 8 "hello.c" 1
+	mov eax, 0
+# 0 "" 2
+#NO_APP
+	mov	eax, 0
+	leave
+	.cfi_restore 5
+	.cfi_def_cfa 4, 4
+	ret
 	.cfi_endproc
 .LFE0:
 	.size	main, .-main
-	.ident	"GCC: (Debian 4.7.2-5) 4.7.2"
+	.ident	"GCC: (Debian 4.8.2-18) 4.8.2"
 	.section	.note.GNU-stack,"",@progbits
Index: /trunk/mioboot-nobios-simple.asm
===================================================================
--- /trunk/mioboot-nobios-simple.asm	(revision 25)
+++ /trunk/mioboot-nobios-simple.asm	(revision 26)
@@ -1,3 +1,3 @@
-;Copyright (C) 2008-2011 by Mattia Monga <mattia.monga@unimi.it>
+;Copyright (C) 2008, 2009 by Mattia Monga <mattia.monga@unimi.it>
 bits 16                         ; 16 bit real mode
 org 0x7C00                      ; origine indirizzo 0000:7C00
Index: /trunk/pthreads-pc.c
===================================================================
--- /trunk/pthreads-pc.c	(revision 25)
+++ /trunk/pthreads-pc.c	(revision 26)
@@ -1,3 +1,3 @@
-/* Copyright (C) 2008 by Mattia Monga <mattia.monga@unimi.it> */
+/* Copyright (C) 2008, 2014 by Mattia Monga <mattia.monga@unimi.it> */
 /* $Id$ */
 #include <pthread.h>
@@ -13,5 +13,5 @@
   while (1){
     char* o = (char*)malloc(sizeof(char));
-    printf("Ho prodotto %x\n", o);
+    printf("Ho prodotto %p\n", o);
     b_insert(o);
   }
@@ -25,5 +25,5 @@
     b_remove(&o);
     free(o);
-    printf("Ho consumato %x\n", o);
+    printf("Ho consumato %p\n", o);
   }
   return NULL;
@@ -56,4 +56,5 @@
 
   while (count == N) pthread_cond_wait(&full, &lock);
+  printf("Buffer a %d\n", count);
   buffer[count++] = o;
   if (count == 1) pthread_cond_signal(&empty);
@@ -68,4 +69,5 @@
 
   while (count == 0) pthread_cond_wait(&empty, &lock);
+  printf("Buffer a %d\n", count);
   *result = buffer[--count];
   if (count == N-1) pthread_cond_signal(&full);
Index: /trunk/syscall.asm
===================================================================
--- /trunk/syscall.asm	(revision 25)
+++ /trunk/syscall.asm	(revision 26)
@@ -1,10 +1,6 @@
 segment .text
 	global main
-	extern printf
 
-main:	push msg
-	call printf		; chiamata di libreria
-
-	mov ecx, msg		; stringa
+main:	mov ecx, msg		; stringa
 	mov edx, msg_size	; dimensione stringa
 	mov ebx, 1         	; file descriptor (stdout)
Index: /trunk/threads-peterson.c
===================================================================
--- /trunk/threads-peterson.c	(revision 25)
+++ /trunk/threads-peterson.c	(revision 26)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */
 /* $Id$ */
-
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <stdio.h>
Index: /trunk/threads-shared.c
===================================================================
--- /trunk/threads-shared.c	(revision 25)
+++ /trunk/threads-shared.c	(revision 26)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */
 /* $Id$ */
-
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <stdio.h>
Index: /trunk/threads-tsl.c
===================================================================
--- /trunk/threads-tsl.c	(revision 25)
+++ /trunk/threads-tsl.c	(revision 26)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */
 /* $Id$ */
+#define _GNU_SOURCE
 
 #include <unistd.h>
@@ -18,4 +19,5 @@
                 printf("Processo figlio (%d). s = %d\n", 
                        getpid(), shared[0]);
+                fflush(stdout);
                 if (!(shared[0] < 10)){
                         printf("Corsa critica!!!!\n");
@@ -25,4 +27,5 @@
                 leave_section(&shared[1]);
                 sched_yield();
+                usleep(50);
         }
         leave_section(&shared[1]); // il test nel while \`e dopo enter\_section
@@ -71,4 +74,5 @@
                        shared[2],
                        shared[3]);
+                fflush(stdout);
         }
         return 0;
