Index: arch/sparc64/src/sparc64.c
===================================================================
--- arch/sparc64/src/sparc64.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ arch/sparc64/src/sparc64.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -58,5 +58,5 @@
          * Create thread that reads characters from OFW's input.
          */
-	t = thread_create(kofwinput, NULL, TASK, 0);
+	t = thread_create(kofwinput, NULL, TASK, 0, "kofwinput");
 	if (!t)
 		panic("cannot create kofwinput\n");
@@ -66,5 +66,5 @@
          * Create thread that polls keyboard.
          */
-	t = thread_create(kkbdpoll, NULL, TASK, 0);
+	t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll");
 	if (!t)
 		panic("cannot create kkbdpoll\n");
Index: generic/include/proc/task.h
===================================================================
--- generic/include/proc/task.h	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/include/proc/task.h	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -38,4 +38,5 @@
 struct task {
 	SPINLOCK_DECLARE(lock);
+	char *name;
 	link_t th_head;		/**< List of threads contained in this task. */
 	link_t tasks_link;	/**< Link to other tasks within the system. */
@@ -53,6 +54,6 @@
 
 extern void task_init(void);
-extern task_t *task_create(as_t *as);
-extern task_t *task_run_program(void * program_addr);
+extern task_t *task_create(as_t *as, char *name);
+extern task_t *task_run_program(void *program_addr, char *name);
 
 #endif
Index: generic/include/proc/thread.h
===================================================================
--- generic/include/proc/thread.h	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/include/proc/thread.h	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -60,5 +60,8 @@
 #define X_STOLEN	(1<<1)
 
+/** Thread structure. There is one per thread. */
 struct thread {
+	char *name;
+	
 	link_t rq_link;				/**< Run queue link. */
 	link_t wq_link;				/**< Wait queue link. */
@@ -126,5 +129,5 @@
 
 extern void thread_init(void);
-extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags);
+extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name);
 extern void thread_ready(thread_t *t);
 extern void thread_exit(void);
Index: generic/src/main/kinit.c
===================================================================
--- generic/src/main/kinit.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/src/main/kinit.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -81,5 +81,5 @@
 		 * Just a beautification.
 		 */
-		if ((t = thread_create(kmp, NULL, TASK, 0))) {
+		if ((t = thread_create(kmp, NULL, TASK, 0, "kmp"))) {
 			spinlock_lock(&t->lock);
 			t->flags |= X_WIRED;
@@ -106,5 +106,5 @@
 		for (i = 0; i < config.cpu_count; i++) {
 
-			if ((t = thread_create(kcpulb, NULL, TASK, 0))) {
+			if ((t = thread_create(kcpulb, NULL, TASK, 0, "kcpulb"))) {
 				spinlock_lock(&t->lock);			
 				t->flags |= X_WIRED;
@@ -127,5 +127,5 @@
 	 * Create kernel console.
 	 */
-	if ((t = thread_create(kconsole, "kconsole", TASK, 0)))
+	if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole")))
 		thread_ready(t);
 	else
@@ -143,5 +143,5 @@
 			panic("init[%d].addr is not frame aligned", i);
 
-		utask = task_run_program((void *) init.tasks[i].addr);
+		utask = task_run_program((void *) init.tasks[i].addr, "USPACE");
 		if (utask) {
 			if (!ipc_phone_0) 
Index: generic/src/main/main.c
===================================================================
--- generic/src/main/main.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/src/main/main.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -197,5 +197,5 @@
 	 * Create kernel task.
 	 */
-	k = task_create(AS_KERNEL);
+	k = task_create(AS_KERNEL, "KERNEL");
 	if (!k)
 		panic("can't create kernel task\n");
@@ -204,5 +204,5 @@
 	 * Create the first thread.
 	 */
-	t = thread_create(kinit, NULL, k, 0);
+	t = thread_create(kinit, NULL, k, 0, "kinit");
 	if (!t)
 		panic("can't create kinit thread\n");
Index: generic/src/proc/scheduler.c
===================================================================
--- generic/src/proc/scheduler.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/src/proc/scheduler.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -618,5 +618,4 @@
 	 * let's not be interrupted */
 	ipl = interrupts_disable();
-	printf("Scheduler dump:\n");
 	for (cpu=0;cpu < config.cpu_count; cpu++) {
 
@@ -625,6 +624,6 @@
 
 		spinlock_lock(&cpus[cpu].lock);
-		printf("cpu%d: nrdy: %d, needs_relink: %d\n",
-		       cpus[cpu].id, atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink);
+		printf("cpu%d: address=%P, nrdy=%d, needs_relink=%d\n",
+		       cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink);
 		
 		for (i=0; i<RQ_COUNT; i++) {
Index: generic/src/proc/task.c
===================================================================
--- generic/src/proc/task.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/src/proc/task.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -63,9 +63,10 @@
  *
  * @param as Task's address space.
+ * @param name Symbolic name.
  *
  * @return New task's structure
  *
  */
-task_t *task_create(as_t *as)
+task_t *task_create(as_t *as, char *name)
 {
 	ipl_t ipl;
@@ -79,4 +80,5 @@
 	list_initialize(&ta->tasks_link);
 	ta->as = as;
+	ta->name = name;
 
 	
@@ -102,7 +104,10 @@
 /** Create new task with 1 thread and run it
  *
+ * @param programe_addr Address of program executable image.
+ * @param name Program name. 
+ *
  * @return Task of the running program or NULL on error
  */
-task_t * task_run_program(void *program_addr)
+task_t * task_run_program(void *program_addr, char *name)
 {
 	as_t *as;
@@ -120,7 +125,7 @@
 	} 
 	
-	task = task_create(as);
+	task = task_create(as, name);
 	t = thread_create(uinit, (void *)((elf_header_t *)program_addr)->e_entry, 
-			  task, THREAD_USER_STACK);
+			  task, 0, "uinit");
 	
 	/*
@@ -149,6 +154,6 @@
 		t = list_get_instance(cur, task_t, tasks_link);
 		spinlock_lock(&t->lock);
-		printf("Task: %Q ActiveCalls: %d", t->taskid, 
-		       atomic_get(&t->active_calls));
+		printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d",
+			t->name, t, t->taskid, t->as, atomic_get(&t->active_calls));
 		for (i=0; i < IPC_MAX_PHONES; i++) {
 			if (t->phones[i].callee)
Index: generic/src/proc/thread.c
===================================================================
--- generic/src/proc/thread.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ generic/src/proc/thread.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -249,9 +249,10 @@
  * @param task  Task to which the thread belongs.
  * @param flags Thread flags.
+ * @param name  Symbolic name.
  *
  * @return New thread's structure on success, NULL on failure.
  *
  */
-thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags)
+thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name)
 {
 	thread_t *t;
@@ -280,4 +281,5 @@
 	interrupts_restore(ipl);
 	
+	t->name = name;
 	t->thread_code = func;
 	t->thread_arg = arg;
@@ -410,7 +412,10 @@
 	for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) {
 		t = list_get_instance(cur, thread_t, threads_link);
-		printf("Thr: %d(%s) ", t->tid, thread_states[t->state]);
+		printf("%s: address=%P, tid=%d, state=%s, task=%P, code=%P, stack=%P, cpu=",
+			t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack);
 		if (t->cpu)
 			printf("cpu%d ", t->cpu->id);
+		else
+			printf("none");
 		printf("\n");
 	}
Index: test/fpu/fpu1/test.c
===================================================================
--- test/fpu/fpu1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/fpu/fpu1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -144,5 +144,4 @@
 }
 
-
 void test(void)
 {
@@ -156,8 +155,8 @@
 
 	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(e, NULL, TASK, 0)))
+		if (!(t = thread_create(e, NULL, TASK, 0, "e")))
 			panic("could not create thread\n");
 		thread_ready(t);
-		if (!(t = thread_create(pi, NULL, TASK, 0)))
+		if (!(t = thread_create(pi, NULL, TASK, 0, "pi")))
 			panic("could not create thread\n");
 		thread_ready(t);
@@ -173,42 +172,2 @@
 	printf("Test passed.\n");
 }
-
-/*
-static void pi(void *data)
-{
-#undef PI_10e8	
-#define PI_10e8	3141592
-
-
-	int i;
-	double lpi, pi;
-	double n, ab, ad;
-
-
-	printf("pi test\n");
-
-	waitq_sleep(&can_start);
-
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		lpi = -1;
-		pi = 0;
-
-		for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
-			double sc, cd;
-
-			sc = sqrt(1 - (ab*ab/4));
-			cd = 1 - sc;
-			ad = sqrt(ab*ab/4 + cd*cd);
-			lpi = pi;
-			pi = 2 * n * ad;
-		}
-
-		atomic_inc(&threads_ok);
-		if((int)(1000000*pi)!=PI_10e8)
-			panic("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
-	}
-
-	printf("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);
-}
-*/
Index: test/fpu/mips1/test.c
===================================================================
--- test/fpu/mips1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/fpu/mips1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -113,8 +113,8 @@
 
 	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0)))
+		if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
 			panic("could not create thread\n");
 		thread_ready(t);
-		if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0)))
+		if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
 			panic("could not create thread\n");
 		thread_ready(t);
Index: test/fpu/sse1/test.c
===================================================================
--- test/fpu/sse1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/fpu/sse1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -113,8 +113,8 @@
 
 	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0)))
+		if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
 			panic("could not create thread\n");
 		thread_ready(t);
-		if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0)))
+		if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
 			panic("could not create thread\n");
 		thread_ready(t);
Index: test/mm/falloc2/test.c
===================================================================
--- test/mm/falloc2/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/mm/falloc2/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -45,10 +45,10 @@
 #define THREADS 8
 
-static void thread(void * arg);
+static void falloc(void * arg);
 static void failed(void);
 
 static atomic_t thread_count;
 
-void thread(void * arg)
+void falloc(void * arg)
 {
 	int status, order, run, allocated, i;
@@ -108,5 +108,5 @@
 	for (i = 0; i < THREADS; i++) {
 		thread_t * thrd;
-		thrd = thread_create(thread, NULL, TASK, 0);
+		thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
 		if (thrd)
 			thread_ready(thrd);
Index: test/mm/slab1/test.c
===================================================================
--- test/mm/slab1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/mm/slab1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -109,5 +109,5 @@
 semaphore_t thr_sem;
 
-static void thread(void *data)
+static void slabtest(void *data)
 {
 	int offs = (int)(__native) data;
@@ -139,5 +139,5 @@
 	semaphore_initialize(&thr_sem,0);
 	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(thread, (void *)(__native)i, TASK, 0)))
+		if (!(t = thread_create(slabtest, (void *)(__native)i, TASK, 0, "slabtest")))
 			panic("could not create thread\n");
 		thread_ready(t);
Index: test/mm/slab2/test.c
===================================================================
--- test/mm/slab2/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/mm/slab2/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -123,5 +123,5 @@
 #define THREADS 8
 
-static void thread(void *priv)
+static void slabtest(void *priv)
 {
 	void *data=NULL, *new;
@@ -189,5 +189,5 @@
 	semaphore_initialize(&thr_sem,0);
 	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(thread, NULL, TASK, 0)))
+		if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
 			panic("could not create thread\n");
 		thread_ready(t);
Index: test/synch/rwlock2/test.c
===================================================================
--- test/synch/rwlock2/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/rwlock2/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -75,5 +75,5 @@
 	rwlock_read_lock(&rwlock);	
 	
-	thrd = thread_create(writer, NULL, TASK, 0);
+	thrd = thread_create(writer, NULL, TASK, 0, "writer");
 	if (thrd)
 		thread_ready(thrd);
Index: test/synch/rwlock3/test.c
===================================================================
--- test/synch/rwlock3/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/rwlock3/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -78,5 +78,5 @@
 	
 	for (i=0; i<4; i++) {
-		thrd = thread_create(reader, NULL, TASK, 0);
+		thrd = thread_create(reader, NULL, TASK, 0, "reader");
 		if (thrd)
 			thread_ready(thrd);
Index: test/synch/rwlock4/test.c
===================================================================
--- test/synch/rwlock4/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/rwlock4/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -138,5 +138,5 @@
 		printf("Creating %d readers\n", k);
 		for (i=0; i<k; i++) {
-			thrd = thread_create(reader, NULL, TASK, 0);
+			thrd = thread_create(reader, NULL, TASK, 0, "reader");
 			if (thrd)
 				thread_ready(thrd);
@@ -148,5 +148,5 @@
 		printf("Creating %d writers\n", k);
 		for (i=0; i<k; i++) {
-			thrd = thread_create(writer, NULL, TASK, 0);
+			thrd = thread_create(writer, NULL, TASK, 0, "writer");
 			if (thrd)
 				thread_ready(thrd);
Index: test/synch/rwlock5/test.c
===================================================================
--- test/synch/rwlock5/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/rwlock5/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -96,5 +96,5 @@
 		for (j=0; j<(READERS+WRITERS)/2; j++) {
 			for (k=0; k<i; k++) {
-				thrd = thread_create(reader, NULL, TASK, 0);
+				thrd = thread_create(reader, NULL, TASK, 0, "reader");
 				if (thrd)
 					thread_ready(thrd);
@@ -103,5 +103,5 @@
 			}
 			for (k=0; k<(4-i); k++) {
-				thrd = thread_create(writer, NULL, TASK, 0);
+				thrd = thread_create(writer, NULL, TASK, 0, "writer");
 				if (thrd)
 					thread_ready(thrd);
Index: test/synch/semaphore1/test.c
===================================================================
--- test/synch/semaphore1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/semaphore1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -100,5 +100,5 @@
 		for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
 			for (k=0; k<i; k++) {
-				thrd = thread_create(consumer, NULL, TASK, 0);
+				thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
 				if (thrd)
 					thread_ready(thrd);
@@ -107,5 +107,5 @@
 			}
 			for (k=0; k<(4-i); k++) {
-				thrd = thread_create(producer, NULL, TASK, 0);
+				thrd = thread_create(producer, NULL, TASK, 0, "producer");
 				if (thrd)
 					thread_ready(thrd);
Index: test/synch/semaphore2/test.c
===================================================================
--- test/synch/semaphore2/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/synch/semaphore2/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -108,5 +108,5 @@
 		printf("Creating %d consumers\n", k);
 		for (i=0; i<k; i++) {
-			thrd = thread_create(consumer, NULL, TASK, 0);
+			thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
 			if (thrd)
 				thread_ready(thrd);
Index: test/thread/thread1/test.c
===================================================================
--- test/thread/thread1/test.c	(revision 37c57f29513b54c8a95f330fce386b8a26dffa7e)
+++ test/thread/thread1/test.c	(revision ff14c520ac9ef1cfa24af4cbbfd3235d2bda51c5)
@@ -40,5 +40,5 @@
 #define THREADS 5
 
-static void thread(void *data)
+static void threadtest(void *data)
 {
     while(1)
@@ -55,5 +55,5 @@
 
 	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(thread, NULL, TASK, 0)))
+		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest")))
 			panic("could not create thread\n");
 		thread_ready(t);
