Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/Makefile	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -231,5 +231,15 @@
 		test/mm/slab1.c \
 		test/mm/slab2.c \
-		test/mm/purge1.c
+		test/mm/purge1.c \
+		test/synch/rwlock1.c \
+		test/synch/rwlock2.c \
+		test/synch/rwlock3.c \
+		test/synch/rwlock4.c \
+		test/synch/rwlock5.c \
+		test/synch/semaphore1.c \
+		test/synch/semaphore2.c \
+		test/print/print1.c \
+		test/thread/thread1.c \
+		test/sysinfo/sysinfo1.c
 endif
 
Index: kernel/test/btree/btree1.c
===================================================================
--- kernel/test/btree/btree1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/btree/btree1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -36,5 +36,5 @@
 #endif
 
-void *data = (void *) 0xdeadbeef;
+static void *data = (void *) 0xdeadbeef;
 
 void test_btree1(void)
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/slab1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -41,5 +41,5 @@
 #define VAL_COUNT   1024
 
-void * data[VAL_COUNT];
+static void * data[VAL_COUNT];
 
 static void testit(int size, int count) 
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/mm/slab2.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -120,8 +120,8 @@
 }
 
-slab_cache_t *thr_cache;
-semaphore_t thr_sem;
-condvar_t thread_starter;
-mutex_t starter_mutex;
+static slab_cache_t *thr_cache;
+static semaphore_t thr_sem;
+static condvar_t thread_starter;
+static mutex_t starter_mutex;
 
 #define THREADS 8
Index: kernel/test/print/print1.c
===================================================================
--- kernel/test/print/print1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/print/print1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <print.h>
+#include <test.h>
+
+#define BUFFER_SIZE 32
+
+void test_print1(void)
+{
+	int retval;
+	unative_t nat = 0x12345678u;
+	
+	char buffer[BUFFER_SIZE];
+	
+	printf(" Printf test \n");
+	
+	printf(" text 10.8s %*.*s \n", 5, 3, "text");
+	printf(" very long text 10.8s %10.8s \n", "very long text");
+	printf(" text 8.10s %8.10s \n", "text");
+	printf(" very long text 8.10s %8.10s \n", "very long text");
+
+	printf(" char: c '%c', 3.2c '%3.2c', -3.2c '%-3.2c', 2.3c '%2.3c', -2.3c '%-2.3c' \n",'a', 'b', 'c', 'd', 'e' );
+	printf(" int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",1, 1, 1, 1, 1 );
+	printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",-1, -1, -1, -1, -1 );
+	printf(" 0xint: x '%#x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n",17, 17, 17, 17, 17 );
+
+	printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
+	
+	printf(" Print to NULL '%s'\n",NULL);
+
+	retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
+	printf("Result is: '%s', retval = %d\n", buffer, retval);
+
+	retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
+	printf("Result is: '%s', retval = %d\n", buffer, retval);
+	
+	printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
+	retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text");
+	printf("Result is: '%s', retval = %d\n", buffer, retval);
+	
+	printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
+	retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE);
+	printf("Result is: '%s', retval = %d\n", buffer, retval);
+	
+	return;
+}
Index: kernel/test/print/print1/test.c
===================================================================
--- kernel/test/print/print1/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*
- * Copyright (C) 2005 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <print.h>
-#include <test.h>
-
-#define BUFFER_SIZE 32
-
-void test(void)
-{
-	int retval;
-	unative_t nat = 0x12345678u;
-	
-	char buffer[BUFFER_SIZE];
-	
-	printf(" Printf test \n");
-	
-	printf(" text 10.8s %*.*s \n", 5, 3, "text");
-	printf(" very long text 10.8s %10.8s \n", "very long text");
-	printf(" text 8.10s %8.10s \n", "text");
-	printf(" very long text 8.10s %8.10s \n", "very long text");
-
-	printf(" char: c '%c', 3.2c '%3.2c', -3.2c '%-3.2c', 2.3c '%2.3c', -2.3c '%-2.3c' \n",'a', 'b', 'c', 'd', 'e' );
-	printf(" int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",1, 1, 1, 1, 1 );
-	printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",-1, -1, -1, -1, -1 );
-	printf(" 0xint: x '%#x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n",17, 17, 17, 17, 17 );
-
-	printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
-	
-	printf(" Print to NULL '%s'\n",NULL);
-
-	retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
-	printf("Result is: '%s', retval = %d\n", buffer, retval);
-
-	retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
-	printf("Result is: '%s', retval = %d\n", buffer, retval);
-	
-	printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
-	retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text");
-	printf("Result is: '%s', retval = %d\n", buffer, retval);
-	
-	printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
-	retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE);
-	printf("Result is: '%s', retval = %d\n", buffer, retval);
-	
-	return;
-}
Index: kernel/test/synch/rwlock1.c
===================================================================
--- kernel/test/synch/rwlock1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/rwlock1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+
+#include <synch/waitq.h>
+#include <synch/rwlock.h>
+
+#define READERS		50
+#define WRITERS		50
+
+static rwlock_t rwlock;
+
+void test_rwlock1(void)
+{
+	printf("Read/write locks test #1\n");
+
+	rwlock_initialize(&rwlock);
+
+	rwlock_write_lock(&rwlock);
+	rwlock_write_unlock(&rwlock);	
+
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);	
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);
+
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);	
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+	
+	
+	rwlock_write_lock(&rwlock);
+	rwlock_write_unlock(&rwlock);	
+
+	rwlock_read_lock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+
+	rwlock_write_lock(&rwlock);
+	rwlock_write_unlock(&rwlock);	
+
+	rwlock_read_lock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+
+	printf("Test passed.\n");
+}
Index: kernel/test/synch/rwlock1/test.c
===================================================================
--- kernel/test/synch/rwlock1/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-
-#include <synch/waitq.h>
-#include <synch/rwlock.h>
-
-#define READERS		50
-#define WRITERS		50
-
-static rwlock_t rwlock;
-
-void test(void)
-{
-	printf("Read/write locks test #1\n");
-
-	rwlock_initialize(&rwlock);
-
-	rwlock_write_lock(&rwlock);
-	rwlock_write_unlock(&rwlock);	
-
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);	
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);
-
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);	
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-	
-	
-	rwlock_write_lock(&rwlock);
-	rwlock_write_unlock(&rwlock);	
-
-	rwlock_read_lock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-
-	rwlock_write_lock(&rwlock);
-	rwlock_write_unlock(&rwlock);	
-
-	rwlock_read_lock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-
-	printf("Test passed.\n");
-}
Index: kernel/test/synch/rwlock2.c
===================================================================
--- kernel/test/synch/rwlock2.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/rwlock2.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+
+#include <synch/rwlock.h>
+
+#define READERS		50
+#define WRITERS		50
+
+static rwlock_t rwlock;
+
+static void writer(void *arg);
+static void failed(void);
+
+static void writer(void *arg)
+{
+
+	thread_detach(THREAD);
+
+	printf("Trying to lock rwlock for writing....\n");    
+
+	rwlock_write_lock(&rwlock);
+	rwlock_write_unlock(&rwlock);
+	
+	printf("Trying to lock rwlock for reading....\n");    	
+	rwlock_read_lock(&rwlock);
+	rwlock_read_unlock(&rwlock);	
+	printf("Test passed.\n");
+}
+
+static void failed()
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_rwlock2(void)
+{
+	thread_t *thrd;
+	
+	printf("Read/write locks test #2\n");
+    
+	rwlock_initialize(&rwlock);
+
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);
+	rwlock_read_lock(&rwlock);	
+	
+	thrd = thread_create(writer, NULL, TASK, 0, "writer");
+	if (thrd)
+		thread_ready(thrd);
+	else
+		failed();
+
+
+	thread_sleep(1);
+	
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);
+	rwlock_read_unlock(&rwlock);	
+
+}
Index: kernel/test/synch/rwlock2/test.c
===================================================================
--- kernel/test/synch/rwlock2/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-
-#include <synch/rwlock.h>
-
-#define READERS		50
-#define WRITERS		50
-
-static rwlock_t rwlock;
-
-static void writer(void *arg);
-static void failed(void);
-
-void writer(void *arg)
-{
-
-	thread_detach(THREAD);
-
-	printf("Trying to lock rwlock for writing....\n");    
-
-	rwlock_write_lock(&rwlock);
-	rwlock_write_unlock(&rwlock);
-	
-	printf("Trying to lock rwlock for reading....\n");    	
-	rwlock_read_lock(&rwlock);
-	rwlock_read_unlock(&rwlock);	
-	printf("Test passed.\n");
-}
-
-void failed()
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	thread_t *thrd;
-	
-	printf("Read/write locks test #2\n");
-    
-	rwlock_initialize(&rwlock);
-
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);
-	rwlock_read_lock(&rwlock);	
-	
-	thrd = thread_create(writer, NULL, TASK, 0, "writer");
-	if (thrd)
-		thread_ready(thrd);
-	else
-		failed();
-
-
-	thread_sleep(1);
-	
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);	
-
-}
Index: kernel/test/synch/rwlock3.c
===================================================================
--- kernel/test/synch/rwlock3.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/rwlock3.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+
+#include <synch/rwlock.h>
+
+#define READERS		50
+#define WRITERS		50
+
+static rwlock_t rwlock;
+
+static void reader(void *arg);
+static void failed(void);
+
+static void reader(void *arg)
+{
+	thread_detach(THREAD);
+
+	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_write_lock(&rwlock);
+	rwlock_write_unlock(&rwlock);
+	printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    			
+	
+	printf("Test passed.\n");	
+
+}
+
+static void failed(void)
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_rwlock3(void)
+{
+	int i;
+	thread_t *thrd;
+	
+	printf("Read/write locks test #3\n");
+    
+	rwlock_initialize(&rwlock);
+
+	rwlock_write_lock(&rwlock);
+	
+	for (i=0; i<4; i++) {
+		thrd = thread_create(reader, NULL, TASK, 0, "reader");
+		if (thrd)
+			thread_ready(thrd);
+		else
+			failed();
+	}
+
+
+	thread_sleep(1);
+	
+	rwlock_write_unlock(&rwlock);
+}
Index: kernel/test/synch/rwlock3/test.c
===================================================================
--- kernel/test/synch/rwlock3/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-
-#include <synch/rwlock.h>
-
-#define READERS		50
-#define WRITERS		50
-
-static rwlock_t rwlock;
-
-static void reader(void *arg);
-static void failed(void);
-
-void reader(void *arg)
-{
-	thread_detach(THREAD);
-
-	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_write_lock(&rwlock);
-	rwlock_write_unlock(&rwlock);
-	printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    			
-	
-	printf("Test passed.\n");	
-
-}
-
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	int i;
-	thread_t *thrd;
-	
-	printf("Read/write locks test #3\n");
-    
-	rwlock_initialize(&rwlock);
-
-	rwlock_write_lock(&rwlock);
-	
-	for (i=0; i<4; i++) {
-		thrd = thread_create(reader, NULL, TASK, 0, "reader");
-		if (thrd)
-			thread_ready(thrd);
-		else
-			failed();
-	}
-
-
-	thread_sleep(1);
-	
-	rwlock_write_unlock(&rwlock);
-}
Index: kernel/test/synch/rwlock4.c
===================================================================
--- kernel/test/synch/rwlock4.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/rwlock4.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+#include <arch/types.h>
+#include <arch/context.h>
+#include <context.h>
+#include <panic.h>
+
+#include <synch/waitq.h>
+#include <synch/rwlock.h>
+#include <synch/synch.h>
+#include <synch/spinlock.h>
+
+#define READERS		50
+#define WRITERS		50
+
+static rwlock_t rwlock;
+
+static SPINLOCK_INITIALIZE(lock);
+
+static waitq_t can_start;
+
+static uint32_t seed = 0xdeadbeef;
+
+static uint32_t random(uint32_t max);
+
+static void writer(void *arg);
+static void reader(void *arg);
+static void failed(void);
+
+static uint32_t random(uint32_t max)
+{
+	uint32_t rc;
+
+	spinlock_lock(&lock);	
+	rc = seed % max;
+	seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
+	spinlock_unlock(&lock);
+	return rc;
+}
+
+
+static void writer(void *arg)
+{
+	int rc, to;
+	thread_detach(THREAD);
+	waitq_sleep(&can_start);
+
+	to = random(40000);
+	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);
+		return;
+	};
+	printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
+
+	if (rwlock.readers_in) panic("Oops.");
+	thread_usleep(random(1000000));
+	if (rwlock.readers_in) panic("Oops.");	
+
+	rwlock_write_unlock(&rwlock);
+	printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);	
+}
+
+static void reader(void *arg)
+{
+	int rc, to;
+	thread_detach(THREAD);
+	waitq_sleep(&can_start);
+	
+	to = random(2000);
+	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);
+		return;
+	}
+	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);		
+}
+
+static void failed(void)
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_rwlock4(void)
+{
+	context_t ctx;
+	uint32_t i, k;
+	
+	printf("Read/write locks test #4\n");
+    
+	waitq_initialize(&can_start);
+	rwlock_initialize(&rwlock);
+	
+	for (;;) {
+		thread_t *thrd;
+		
+		context_save(&ctx);
+		printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
+		
+		k = random(7) + 1;
+		printf("Creating %d readers\n", k);
+		for (i=0; i<k; i++) {
+			thrd = thread_create(reader, NULL, TASK, 0, "reader");
+			if (thrd)
+				thread_ready(thrd);
+			else
+				failed();
+		}
+
+		k = random(5) + 1;
+		printf("Creating %d writers\n", k);
+		for (i=0; i<k; i++) {
+			thrd = thread_create(writer, NULL, TASK, 0, "writer");
+			if (thrd)
+				thread_ready(thrd);
+			else
+				failed();
+		}
+		
+		thread_usleep(20000);
+		waitq_wakeup(&can_start, WAKEUP_ALL);
+	}		
+
+}
Index: kernel/test/synch/rwlock4/test.c
===================================================================
--- kernel/test/synch/rwlock4/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,161 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-#include <arch/types.h>
-#include <arch/context.h>
-#include <context.h>
-#include <panic.h>
-
-#include <synch/waitq.h>
-#include <synch/rwlock.h>
-#include <synch/synch.h>
-#include <synch/spinlock.h>
-
-#define READERS		50
-#define WRITERS		50
-
-static rwlock_t rwlock;
-
-SPINLOCK_INITIALIZE(lock);
-
-static waitq_t can_start;
-
-uint32_t seed = 0xdeadbeef;
-
-static uint32_t random(uint32_t max);
-
-static void writer(void *arg);
-static void reader(void *arg);
-static void failed(void);
-
-uint32_t random(uint32_t max)
-{
-	uint32_t rc;
-
-	spinlock_lock(&lock);	
-	rc = seed % max;
-	seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
-	spinlock_unlock(&lock);
-	return rc;
-}
-
-
-void writer(void *arg)
-{
-	int rc, to;
-	thread_detach(THREAD);
-	waitq_sleep(&can_start);
-
-	to = random(40000);
-	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);
-		return;
-	};
-	printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
-
-	if (rwlock.readers_in) panic("Oops.");
-	thread_usleep(random(1000000));
-	if (rwlock.readers_in) panic("Oops.");	
-
-	rwlock_write_unlock(&rwlock);
-	printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);	
-}
-
-void reader(void *arg)
-{
-	int rc, to;
-	thread_detach(THREAD);
-	waitq_sleep(&can_start);
-	
-	to = random(2000);
-	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);
-		return;
-	}
-	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);		
-}
-
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	context_t ctx;
-	uint32_t i, k;
-	
-	printf("Read/write locks test #4\n");
-    
-	waitq_initialize(&can_start);
-	rwlock_initialize(&rwlock);
-	
-	for (;;) {
-		thread_t *thrd;
-		
-		context_save(&ctx);
-		printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
-		
-		k = random(7) + 1;
-		printf("Creating %d readers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(reader, NULL, TASK, 0, "reader");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
-
-		k = random(5) + 1;
-		printf("Creating %d writers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(writer, NULL, TASK, 0, "writer");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
-		
-		thread_usleep(20000);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	}		
-
-}
Index: kernel/test/synch/rwlock5.c
===================================================================
--- kernel/test/synch/rwlock5.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/rwlock5.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+
+#include <synch/waitq.h>
+#include <synch/rwlock.h>
+
+#define READERS		50
+#define WRITERS		50
+
+static rwlock_t rwlock;
+
+static waitq_t can_start;
+static atomic_t items_read;
+static atomic_t items_written;
+
+static void writer(void *arg);
+static void reader(void *arg);
+static void failed(void);
+
+void writer(void *arg)
+{
+	thread_detach(THREAD);
+
+	waitq_sleep(&can_start);
+
+	rwlock_write_lock(&rwlock);
+	atomic_inc(&items_written);
+	rwlock_write_unlock(&rwlock);
+}
+
+void reader(void *arg)
+{
+	thread_detach(THREAD);
+
+	waitq_sleep(&can_start);
+	
+	rwlock_read_lock(&rwlock);
+	atomic_inc(&items_read);
+	rwlock_read_unlock(&rwlock);
+}
+
+void failed(void)
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_rwlock5(void)
+{
+	int i, j, k;
+	count_t readers, writers;
+	
+	printf("Read/write locks test #5\n");
+    
+	waitq_initialize(&can_start);
+	rwlock_initialize(&rwlock);
+	
+	for (i=1; i<=3; i++) {
+		thread_t *thrd;
+
+		atomic_set(&items_read, 0);
+		atomic_set(&items_written, 0);
+
+		readers = i*READERS;
+		writers = (4-i)*WRITERS;
+
+		printf("Creating %ld readers and %ld writers...", readers, writers);
+		
+		for (j=0; j<(READERS+WRITERS)/2; j++) {
+			for (k=0; k<i; k++) {
+				thrd = thread_create(reader, NULL, TASK, 0, "reader");
+				if (thrd)
+					thread_ready(thrd);
+				else
+					failed();
+			}
+			for (k=0; k<(4-i); k++) {
+				thrd = thread_create(writer, NULL, TASK, 0, "writer");
+				if (thrd)
+					thread_ready(thrd);
+				else
+					failed();
+			}
+		}
+
+		printf("ok\n");
+
+		thread_sleep(1);
+		waitq_wakeup(&can_start, WAKEUP_ALL);
+	
+		while (items_read.count != readers || items_written.count != writers) {
+			printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
+			thread_usleep(100000);
+		}
+	}
+	printf("Test passed.\n");
+}
Index: kernel/test/synch/rwlock5/test.c
===================================================================
--- kernel/test/synch/rwlock5/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,128 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-
-#include <synch/waitq.h>
-#include <synch/rwlock.h>
-
-#define READERS		50
-#define WRITERS		50
-
-static rwlock_t rwlock;
-
-static waitq_t can_start;
-static atomic_t items_read;
-static atomic_t items_written;
-
-static void writer(void *arg);
-static void reader(void *arg);
-static void failed(void);
-
-void writer(void *arg)
-{
-	thread_detach(THREAD);
-
-	waitq_sleep(&can_start);
-
-	rwlock_write_lock(&rwlock);
-	atomic_inc(&items_written);
-	rwlock_write_unlock(&rwlock);
-}
-
-void reader(void *arg)
-{
-	thread_detach(THREAD);
-
-	waitq_sleep(&can_start);
-	
-	rwlock_read_lock(&rwlock);
-	atomic_inc(&items_read);
-	rwlock_read_unlock(&rwlock);
-}
-
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	int i, j, k;
-	count_t readers, writers;
-	
-	printf("Read/write locks test #5\n");
-    
-	waitq_initialize(&can_start);
-	rwlock_initialize(&rwlock);
-	
-	for (i=1; i<=3; i++) {
-		thread_t *thrd;
-
-		atomic_set(&items_read, 0);
-		atomic_set(&items_written, 0);
-
-		readers = i*READERS;
-		writers = (4-i)*WRITERS;
-
-		printf("Creating %ld readers and %ld writers...", readers, writers);
-		
-		for (j=0; j<(READERS+WRITERS)/2; j++) {
-			for (k=0; k<i; k++) {
-				thrd = thread_create(reader, NULL, TASK, 0, "reader");
-				if (thrd)
-					thread_ready(thrd);
-				else
-					failed();
-			}
-			for (k=0; k<(4-i); k++) {
-				thrd = thread_create(writer, NULL, TASK, 0, "writer");
-				if (thrd)
-					thread_ready(thrd);
-				else
-					failed();
-			}
-		}
-
-		printf("ok\n");
-
-		thread_sleep(1);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	
-		while (items_read.count != readers || items_written.count != writers) {
-			printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
-			thread_usleep(100000);
-		}
-	}
-	printf("Test passed.\n");
-}
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/semaphore1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+
+#include <synch/waitq.h>
+#include <synch/semaphore.h>
+
+#define AT_ONCE			3
+#define PRODUCERS		50
+#define CONSUMERS		50
+
+static semaphore_t sem;
+
+static waitq_t can_start;
+static atomic_t items_produced;
+static atomic_t items_consumed;
+
+static void consumer(void *arg);
+static void producer(void *arg);
+static void failed(void);
+
+static void producer(void *arg)
+{
+	thread_detach(THREAD);	
+
+	waitq_sleep(&can_start);
+	    
+	semaphore_down(&sem);
+	atomic_inc(&items_produced);
+	thread_usleep(250);
+	semaphore_up(&sem);
+}
+
+static void consumer(void *arg)
+{
+	thread_detach(THREAD);	
+	
+	waitq_sleep(&can_start);
+	
+	semaphore_down(&sem);
+	atomic_inc(&items_consumed);
+	thread_usleep(500);
+	semaphore_up(&sem);
+}
+
+static void failed(void)
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_semaphore1(void)
+{
+	int i, j, k;
+	int consumers, producers;
+	
+	printf("Semaphore test #1\n");
+    
+	waitq_initialize(&can_start);
+	semaphore_initialize(&sem, AT_ONCE);
+
+
+	for (i=1; i<=3; i++) {
+		thread_t *thrd;
+
+		atomic_set(&items_produced, 0);
+		atomic_set(&items_consumed, 0);
+		
+		consumers = i * CONSUMERS;
+		producers = (4-i) * PRODUCERS;
+		
+		printf("Creating %d consumers and %d producers...", consumers, producers);
+	
+		for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
+			for (k=0; k<i; k++) {
+				thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
+				if (thrd)
+					thread_ready(thrd);
+				else
+					failed();
+			}
+			for (k=0; k<(4-i); k++) {
+				thrd = thread_create(producer, NULL, TASK, 0, "producer");
+				if (thrd)
+					thread_ready(thrd);
+				else
+					failed();
+			}
+		}
+
+		printf("ok\n");
+
+		thread_sleep(1);
+		waitq_wakeup(&can_start, WAKEUP_ALL);
+	
+		while (items_consumed.count != consumers || items_produced.count != producers) {
+			printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
+			thread_sleep(1);
+		}
+	}
+	printf("Test passed.\n");
+}
Index: kernel/test/synch/semaphore1/test.c
===================================================================
--- kernel/test/synch/semaphore1/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,132 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-
-#include <synch/waitq.h>
-#include <synch/semaphore.h>
-
-#define AT_ONCE			3
-#define PRODUCERS		50
-#define CONSUMERS		50
-
-static semaphore_t sem;
-
-static waitq_t can_start;
-static atomic_t items_produced;
-static atomic_t items_consumed;
-
-static void consumer(void *arg);
-static void producer(void *arg);
-static void failed(void);
-
-void producer(void *arg)
-{
-	thread_detach(THREAD);	
-
-	waitq_sleep(&can_start);
-	    
-	semaphore_down(&sem);
-	atomic_inc(&items_produced);
-	thread_usleep(250);
-	semaphore_up(&sem);
-}
-
-void consumer(void *arg)
-{
-	thread_detach(THREAD);	
-	
-	waitq_sleep(&can_start);
-	
-	semaphore_down(&sem);
-	atomic_inc(&items_consumed);
-	thread_usleep(500);
-	semaphore_up(&sem);
-}
-
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	int i, j, k;
-	int consumers, producers;
-	
-	printf("Semaphore test #1\n");
-    
-	waitq_initialize(&can_start);
-	semaphore_initialize(&sem, AT_ONCE);
-
-
-	for (i=1; i<=3; i++) {
-		thread_t *thrd;
-
-		atomic_set(&items_produced, 0);
-		atomic_set(&items_consumed, 0);
-		
-		consumers = i * CONSUMERS;
-		producers = (4-i) * PRODUCERS;
-		
-		printf("Creating %d consumers and %d producers...", consumers, producers);
-	
-		for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
-			for (k=0; k<i; k++) {
-				thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
-				if (thrd)
-					thread_ready(thrd);
-				else
-					failed();
-			}
-			for (k=0; k<(4-i); k++) {
-				thrd = thread_create(producer, NULL, TASK, 0, "producer");
-				if (thrd)
-					thread_ready(thrd);
-				else
-					failed();
-			}
-		}
-
-		printf("ok\n");
-
-		thread_sleep(1);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	
-		while (items_consumed.count != consumers || items_produced.count != producers) {
-			printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
-			thread_sleep(1);
-		}
-	}
-	printf("Test passed.\n");
-}
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/synch/semaphore2.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <arch.h>
+#include <atomic.h>
+#include <print.h>
+#include <proc/thread.h>
+#include <arch/types.h>
+#include <arch/context.h>
+
+#include <synch/waitq.h>
+#include <synch/semaphore.h>
+#include <synch/synch.h>
+#include <synch/spinlock.h>
+
+static semaphore_t sem;
+
+static SPINLOCK_INITIALIZE(lock);
+
+static waitq_t can_start;
+
+static uint32_t seed = 0xdeadbeef;
+
+static uint32_t random(uint32_t max);
+
+static void consumer(void *arg);
+static void failed(void);
+
+static uint32_t random(uint32_t max)
+{
+	uint32_t rc;
+
+	spinlock_lock(&lock);	
+	rc = seed % max;
+	seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
+	spinlock_unlock(&lock);
+	return rc;
+}
+
+
+static void consumer(void *arg)
+{
+	int rc, to;
+	
+	thread_detach(THREAD);
+	
+	waitq_sleep(&can_start);
+	
+	to = random(20000);
+	printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
+	rc = semaphore_down_timeout(&sem, to);
+	if (SYNCH_FAILED(rc)) {
+		printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
+		return;
+	}
+	
+	printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid);	
+	thread_usleep(random(30000));
+	
+	semaphore_up(&sem);
+	printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
+}
+
+static void failed(void)
+{
+	printf("Test failed prematurely.\n");
+	thread_exit();
+}
+
+void test_semaphore2(void)
+{
+	uint32_t i, k;
+	
+	printf("Semaphore test #2\n");
+    
+	waitq_initialize(&can_start);
+	semaphore_initialize(&sem, 5);
+	
+
+	
+	for (; ;) {
+		thread_t *thrd;
+		
+		k = random(7) + 1;
+		printf("Creating %d consumers\n", k);
+		for (i=0; i<k; i++) {
+			thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
+			if (thrd)
+				thread_ready(thrd);
+			else
+				failed();
+		}
+		
+		thread_usleep(20000);
+		waitq_wakeup(&can_start, WAKEUP_ALL);
+	}		
+
+}
Index: kernel/test/synch/semaphore2/test.c
===================================================================
--- kernel/test/synch/semaphore2/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*
- * Copyright (C) 2001-2004 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <arch.h>
-#include <atomic.h>
-#include <print.h>
-#include <proc/thread.h>
-#include <arch/types.h>
-#include <arch/context.h>
-
-#include <synch/waitq.h>
-#include <synch/semaphore.h>
-#include <synch/synch.h>
-#include <synch/spinlock.h>
-
-static semaphore_t sem;
-
-SPINLOCK_INITIALIZE(lock);
-
-static waitq_t can_start;
-
-uint32_t seed = 0xdeadbeef;
-
-static uint32_t random(uint32_t max);
-
-static void consumer(void *arg);
-static void failed(void);
-
-uint32_t random(uint32_t max)
-{
-	uint32_t rc;
-
-	spinlock_lock(&lock);	
-	rc = seed % max;
-	seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
-	spinlock_unlock(&lock);
-	return rc;
-}
-
-
-void consumer(void *arg)
-{
-	int rc, to;
-	
-	thread_detach(THREAD);
-	
-	waitq_sleep(&can_start);
-	
-	to = random(20000);
-	printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
-	rc = semaphore_down_timeout(&sem, to);
-	if (SYNCH_FAILED(rc)) {
-		printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
-		return;
-	}
-	
-	printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid);	
-	thread_usleep(random(30000));
-	
-	semaphore_up(&sem);
-	printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
-}
-
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test(void)
-{
-	uint32_t i, k;
-	
-	printf("Semaphore test #2\n");
-    
-	waitq_initialize(&can_start);
-	semaphore_initialize(&sem, 5);
-	
-
-	
-	for (; ;) {
-		thread_t *thrd;
-		
-		k = random(7) + 1;
-		printf("Creating %d consumers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
-		
-		thread_usleep(20000);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	}		
-
-}
Index: kernel/test/sysinfo/sysinfo1.c
===================================================================
--- kernel/test/sysinfo/sysinfo1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/sysinfo/sysinfo1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005 Jakub Vana
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <sysinfo/sysinfo.h>
+/*
+static unative_t counter(sysinfo_item_t *root)
+{
+	static unative_t i=0;
+	return i++;
+}*/
+
+void test_sysinfo1(void)
+{
+/*	sysinfo_set_item_val("Ahoj.lidi.uaaaa",NULL,9);
+	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,15);
+	sysinfo_set_item_val("Ahoj.lidi",NULL,64);
+	sysinfo_set_item_function("Ahoj",NULL,counter);
+	sysinfo_dump(NULL,0);
+	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,75);
+	sysinfo_dump(NULL,0);
+	sysinfo_dump(NULL,0);
+	sysinfo_dump(NULL,0);*/
+	sysinfo_dump(NULL,0);
+}
Index: kernel/test/sysinfo/test.c
===================================================================
--- kernel/test/sysinfo/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Vana
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <sysinfo/sysinfo.h>
-/*
-static unative_t counter(sysinfo_item_t *root)
-{
-	static unative_t i=0;
-	return i++;
-}*/
-
-void test(void)
-{
-/*	sysinfo_set_item_val("Ahoj.lidi.uaaaa",NULL,9);
-	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,15);
-	sysinfo_set_item_val("Ahoj.lidi",NULL,64);
-	sysinfo_set_item_function("Ahoj",NULL,counter);
-	sysinfo_dump(NULL,0);
-	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,75);
-	sysinfo_dump(NULL,0);
-	sysinfo_dump(NULL,0);
-	sysinfo_dump(NULL,0);*/
-	sysinfo_dump(NULL,0);
-	
-}
Index: kernel/test/test.c
===================================================================
--- kernel/test/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/test.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -114,4 +114,64 @@
 		true
 	},
+	{
+		"rwlock1",
+		"RW-lock test 1",
+		&test_rwlock1,
+		true
+	},
+	{
+		"rwlock2",
+		"RW-lock test 2",
+		&test_rwlock2,
+		true
+	},
+	{
+		"rwlock3",
+		"RW-lock test 3",
+		&test_rwlock3,
+		true
+	},
+	{
+		"rwlock4",
+		"RW-lock test 4",
+		&test_rwlock4,
+		true
+	},
+	{
+		"rwlock5",
+		"RW-lock test 5",
+		&test_rwlock5,
+		true
+	},
+	{
+		"semaphore1",
+		"Semaphore test 1",
+		&test_semaphore1,
+		true
+	},
+	{
+		"semaphore2",
+		"Semaphore test 2",
+		&test_semaphore2,
+		true
+	},
+	{
+		"print1",
+		"Printf test",
+		&test_print1,
+		true
+	},
+	{
+		"thread1",
+		"Thread test",
+		&test_thread1,
+		true
+	},
+	{
+		"sysinfo1",
+		"Sysinfo test",
+		&test_sysinfo1,
+		true
+	},
 	{NULL, NULL, NULL}
 };
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ kernel/test/test.h	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -59,4 +59,14 @@
 extern void test_slab1(void);
 extern void test_slab2(void);
+extern void test_rwlock1(void);
+extern void test_rwlock2(void);
+extern void test_rwlock3(void);
+extern void test_rwlock4(void);
+extern void test_rwlock5(void);
+extern void test_semaphore1(void);
+extern void test_semaphore2(void);
+extern void test_print1(void);
+extern void test_thread1(void);
+extern void test_sysinfo1(void);
 
 extern test_t tests[];
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
+++ kernel/test/thread/thread1.c	(revision 70b6de17d76360ed8d3b167e184fa20dc135a760)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2005 Jakub Vana
+ * Copyright (C) 2005 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+
+#include <arch.h>
+
+#define THREADS 5
+
+static void threadtest(void *data)
+{
+
+	thread_detach(THREAD);	
+
+	while (1)
+		printf("%d\n",(int)(THREAD->tid));
+}
+
+void test_thread1(void)
+{
+	thread_t *t;
+	int i;
+
+	for (i=0; i<THREADS; i++) {  
+		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+	printf("ok\n");
+}
Index: kernel/test/thread/thread1/test.c
===================================================================
--- kernel/test/thread/thread1/test.c	(revision f272cb8ed4a2b60396822afbeb6a9092d627b44f)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Vana
- * Copyright (C) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-
-#include <arch.h>
-
-#define THREADS 5
-
-static void threadtest(void *data)
-{
-
-	thread_detach(THREAD);	
-
-	while (1)
-		printf("%d\n",(int)(THREAD->tid));
-}
-
-void test(void)
-{
-	thread_t *t;
-	int i;
-
-	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-	printf("ok\n");
-}
