Index: kernel/test/synch/rwlock1.c
===================================================================
--- kernel/test/synch/rwlock1.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
+++ kernel/test/synch/rwlock1.c	(revision c109dd0d57e16b366a742aafd75aacb6224d94bd)
@@ -60,5 +60,4 @@
 	rwlock_read_unlock(&rwlock);
 	
-	
 	rwlock_write_lock(&rwlock);
 	rwlock_write_unlock(&rwlock);	
Index: kernel/test/synch/rwlock2.c
===================================================================
--- kernel/test/synch/rwlock2.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
+++ kernel/test/synch/rwlock2.c	(revision c109dd0d57e16b366a742aafd75aacb6224d94bd)
@@ -39,19 +39,19 @@
 
 static rwlock_t rwlock;
+static bool sh_quiet;
 
 static void writer(void *arg)
 {
-
-	thread_detach(THREAD);
-
-	printf("Trying to lock rwlock for writing....\n");    
-
+	if (!sh_quiet)
+		printf("Trying to lock rwlock for writing....\n");
+	
 	rwlock_write_lock(&rwlock);
 	rwlock_write_unlock(&rwlock);
 	
-	printf("Trying to lock rwlock for reading....\n");    	
+	if (!sh_quiet)
+		printf("Trying to lock rwlock for reading....\n");
+	
 	rwlock_read_lock(&rwlock);
 	rwlock_read_unlock(&rwlock);	
-	printf("Test passed.\n");
 }
 
@@ -59,4 +59,5 @@
 {
 	thread_t *thrd;
+	sh_quiet = quiet;
 	
 	rwlock_initialize(&rwlock);
@@ -80,4 +81,7 @@
 	rwlock_read_unlock(&rwlock);
 	
+	thread_join(thrd);
+	thread_detach(thrd);
+	
 	return NULL;
 }
Index: kernel/test/synch/rwlock3.c
===================================================================
--- kernel/test/synch/rwlock3.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
+++ kernel/test/synch/rwlock3.c	(revision c109dd0d57e16b366a742aafd75aacb6224d94bd)
@@ -35,23 +35,32 @@
 #include <synch/rwlock.h>
 
-#define READERS		50
-#define WRITERS		50
+#define THREADS	4
 
+static atomic_t thread_count;
 static rwlock_t rwlock;
+static bool sh_quiet;
 
 static void reader(void *arg)
 {
 	thread_detach(THREAD);
-
-	printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);    	
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
+	
 	rwlock_read_lock(&rwlock);
-	rwlock_read_unlock(&rwlock);	
-	printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    		
-
-	printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);    	
+	rwlock_read_unlock(&rwlock);
+	
+	if (!sh_quiet) {
+		printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    		
+		printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);    	
+	}
 
 	rwlock_write_lock(&rwlock);
 	rwlock_write_unlock(&rwlock);
-	printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    			
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
+	
+	atomic_dec(&thread_count);
 }
 
@@ -60,19 +69,27 @@
 	int i;
 	thread_t *thrd;
+	sh_quiet = quiet;
+	
+	atomic_set(&thread_count, THREADS);
 	
 	rwlock_initialize(&rwlock);
 	rwlock_write_lock(&rwlock);
 	
-	for (i = 0; i < 4; i++) {
+	for (i = 0; i < THREADS; i++) {
 		thrd = thread_create(reader, NULL, TASK, 0, "reader", false);
 		if (thrd)
 			thread_ready(thrd);
-		else
+		else if (!quiet)
 			printf("Could not create reader %d\n", i);
 	}
 
 	thread_sleep(1);
+	rwlock_write_unlock(&rwlock);
 	
-	rwlock_write_unlock(&rwlock);
+	while (atomic_get(&thread_count) > 0) {
+		if (!quiet)
+			printf("Threads left: %d\n", atomic_get(&thread_count));
+		thread_sleep(1);
+	}
 	
 	return NULL;
Index: kernel/test/synch/rwlock4.c
===================================================================
--- kernel/test/synch/rwlock4.c	(revision 95155b0cd020d126e09ca42230ae0a4dce3f296c)
+++ kernel/test/synch/rwlock4.c	(revision c109dd0d57e16b366a742aafd75aacb6224d94bd)
@@ -44,6 +44,8 @@
 #define WRITERS		50
 
+static atomic_t thread_count;
 static rwlock_t rwlock;
 static atomic_t threads_fault;
+static bool sh_quiet;
 
 SPINLOCK_INITIALIZE(rw_lock);
@@ -71,26 +73,40 @@
 
 	to = random(40000);
-	printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
+	
 	rc = rwlock_write_lock_timeout(&rwlock, to);
 	if (SYNCH_FAILED(rc)) {
-		printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
+		if (!sh_quiet)
+			printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
+		atomic_dec(&thread_count);
 		return;
 	}
-	printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
 
 	if (rwlock.readers_in) {
-		printf("Oops.");
+		if (!sh_quiet)
+			printf("Oops.");
 		atomic_inc(&threads_fault);
+		atomic_dec(&thread_count);
 		return;
 	}
 	thread_usleep(random(1000000));
 	if (rwlock.readers_in) {
-		printf("Oops.");	
+		if (!sh_quiet)
+			printf("Oops.");	
 		atomic_inc(&threads_fault);
+		atomic_dec(&thread_count);
 		return;
 	}
 
 	rwlock_write_unlock(&rwlock);
-	printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);	
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);
+	atomic_dec(&thread_count);
 }
 
@@ -102,14 +118,25 @@
 	
 	to = random(2000);
-	printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
+	
 	rc = rwlock_read_lock_timeout(&rwlock, to);
 	if (SYNCH_FAILED(rc)) {
-		printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
+		if (!sh_quiet)
+			printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
+		atomic_dec(&thread_count);
 		return;
 	}
-	printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
+	
 	thread_usleep(30000);
 	rwlock_read_unlock(&rwlock);
-	printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);		
+	
+	if (!sh_quiet)
+		printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);
+	atomic_dec(&thread_count);
 }
 
@@ -117,5 +144,6 @@
 {
 	context_t ctx;
-	uint32_t i, k;
+	uint32_t i;
+	sh_quiet = quiet;
 	
 	waitq_initialize(&can_start);
@@ -123,26 +151,33 @@
 	atomic_set(&threads_fault, 0);
 	
+	uint32_t rd = random(7) + 1;
+	uint32_t wr = random(5) + 1;
+	
+	atomic_set(&thread_count, rd + wr);
+	
 	thread_t *thrd;
 	
 	context_save(&ctx);
-	printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
+	if (!quiet) {
+		printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
+		printf("Creating %d readers\n", rd);
+	}
 	
-	k = random(7) + 1;
-	printf("Creating %d readers\n", k);
-	for (i = 0; i < k; i++) {
+	for (i = 0; i < rd; i++) {
 		thrd = thread_create(reader, NULL, TASK, 0, "reader", false);
 		if (thrd)
 			thread_ready(thrd);
-		else
+		else if (!quiet)
 			printf("Could not create reader %d\n", i);
 	}
 
-	k = random(5) + 1;
-	printf("Creating %d writers\n", k);
-	for (i = 0; i < k; i++) {
+	if (!quiet)
+		printf("Creating %d writers\n", wr);
+	
+	for (i = 0; i < wr; i++) {
 		thrd = thread_create(writer, NULL, TASK, 0, "writer", false);
 		if (thrd)
 			thread_ready(thrd);
-		else
+		else if (!quiet)
 			printf("Could not create writer %d\n", i);
 	}
@@ -151,4 +186,10 @@
 	waitq_wakeup(&can_start, WAKEUP_ALL);
 	
+	while (atomic_get(&thread_count) > 0) {
+		if (!quiet)
+			printf("Threads left: %d\n", atomic_get(&thread_count));
+		thread_sleep(1);
+	}
+	
 	if (atomic_get(&threads_fault) == 0)
 		return NULL;
