Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/include/proc/task.h	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -83,4 +83,6 @@
 	mutex_t futexes_lock;
 	btree_t futexes;	/**< B+tree of futexes referenced by this task. */
+	
+	uint64_t cycles;	/**< Accumulated accounting. */
 };
 
@@ -94,4 +96,5 @@
 extern task_t *task_find_by_id(task_id_t id);
 extern int task_kill(task_id_t id);
+extern uint64_t task_get_accounting(task_t *t);
 
 
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/src/console/cmd.c	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -57,4 +57,5 @@
 #include <mm/tlb.h>
 #include <arch/mm/tlb.h>
+#include <mm/as.h>
 #include <mm/frame.h>
 #include <main/version.h>
@@ -859,15 +860,14 @@
 }
 
-static bool run_test(const test_t * test)
-{
-	printf("%s\t\t%s\n", test->name, test->desc);
+static void test_wrapper(void *arg)
+{
+	test_t *test = (test_t *) arg;
 	
 	/* Update and read thread accounting
 	   for benchmarking */
 	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&THREAD->lock);
-	thread_update_accounting();
-	uint64_t t0 = THREAD->cycles;
-	spinlock_unlock(&THREAD->lock);
+	spinlock_lock(&TASK->lock);
+	uint64_t t0 = task_get_accounting(TASK);
+	spinlock_unlock(&TASK->lock);
 	interrupts_restore(ipl);
 	
@@ -877,8 +877,7 @@
 	/* Update and read thread accounting */
 	ipl = interrupts_disable();
-	spinlock_lock(&THREAD->lock);
-	thread_update_accounting();
-	uint64_t dt = THREAD->cycles - t0;
-	spinlock_unlock(&THREAD->lock);
+	spinlock_lock(&TASK->lock);
+	uint64_t dt = task_get_accounting(TASK) - t0;
+	spinlock_unlock(&TASK->lock);
 	interrupts_restore(ipl);
 	
@@ -887,9 +886,37 @@
 	if (ret == NULL) {
 		printf("Test passed\n");
-		return true;
+//		return true;
+		return;
 	}
 
 	printf("%s\n", ret);
-	return false;
+//	return false;
+}
+
+static bool run_test(const test_t *test)
+{
+	printf("%s\t\t%s\n", test->name, test->desc);
+	
+	/* Create separate task and thread
+	   for the test */
+	task_t *ta = task_create(AS_KERNEL, "test");
+	if (ta == NULL) {
+		printf("Unable to create test task\n");
+		return false;
+	}
+	
+	thread_t *t = thread_create(test_wrapper, (void *) test, ta, 0, "test_main");
+	if (t == NULL) {
+		printf("Unable to create test main thread\n");
+		task_destroy(ta);
+		return false;
+	}
+	
+	/* Run the test */
+	thread_ready(t);
+	thread_join(t);
+	thread_detach(t);
+	
+	return true;
 }
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/src/main/kinit.c	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -162,5 +162,5 @@
 		}
 
-		task_t *utask = task_run_program((void *) init.tasks[i].addr, "USPACE");
+		task_t *utask = task_run_program((void *) init.tasks[i].addr, "uspace");
 		if (utask) {
 			/*
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/src/main/main.c	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -260,5 +260,5 @@
 	 * Create kernel task.
 	 */
-	k = task_create(AS_KERNEL, "KERNEL");
+	k = task_create(AS_KERNEL, "kernel");
 	if (!k)
 		panic("can't create kernel task\n");
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/src/proc/task.c	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -120,4 +120,5 @@
 	ta->capabilities = 0;
 	ta->accept_new_threads = true;
+	ta->cycles = 0;
 	
 	ipc_answerbox_init(&ta->answerbox);
@@ -267,4 +268,34 @@
 }
 
+/** Get accounting data of given task.
+ *
+ * Note that task_lock on @t must be already held and
+ * interrupts must be already disabled.
+ *
+ * @param t Pointer to thread.
+ *
+ */
+uint64_t task_get_accounting(task_t *t)
+{
+	/* Accumulated value of task */
+	uint64_t ret = t->cycles;
+	
+	/* Current values of threads */
+	link_t *cur;
+	for (cur = t->th_head.next; cur != &t->th_head; cur = cur->next) {
+		thread_t *thr = list_get_instance(cur, thread_t, th_link);
+		
+		spinlock_lock(&thr->lock);
+		
+		if (thr == THREAD) /* Update accounting of current thread */
+			thread_update_accounting(); 
+		ret += thr->cycles;
+		
+		spinlock_unlock(&thr->lock);
+	}
+	
+	return ret;
+}
+
 /** Kill task.
  *
@@ -345,6 +376,6 @@
 	spinlock_lock(&tasks_lock);
 	
-	printf("taskid name       ctx address    as         active calls callee\n");
-	printf("------ ---------- --- ---------- ---------- ------------ ------>\n");
+	printf("taskid name       ctx address    as         cycles     threads calls  callee\n");
+	printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n");
 
 	for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
@@ -360,5 +391,21 @@
 		
 			spinlock_lock(&t->lock);
-			printf("%-6lld %-10s %-3ld %#10zx %#10zx %12zd", t->taskid, t->name, t->context, t, t->as, atomic_get(&t->active_calls));
+			
+			uint64_t cycles = task_get_accounting(t);
+			char suffix;
+			
+			if (cycles > 1000000000000000000LL) {
+				cycles = cycles / 1000000000000000000LL;
+				suffix = 'E';
+			} else if (cycles > 1000000000000LL) {
+				cycles = cycles / 1000000000000LL;
+				suffix = 'T';
+			} else if (cycles > 1000000LL) {
+				cycles = cycles / 1000000LL;
+				suffix = 'M';
+			} else 
+				suffix = ' ';
+			
+			printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls));
 			for (j = 0; j < IPC_MAX_PHONES; j++) {
 				if (t->phones[j].callee)
@@ -366,4 +413,5 @@
 			}
 			printf("\n");
+			
 			spinlock_unlock(&t->lock);
 		}
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision cd896e26b27f7c29d75d04d6d8a133a42f7ebe4a)
+++ kernel/generic/src/proc/thread.c	(revision 0313ff0ebb436deb6a48b67d17b944f3fc79f731)
@@ -114,9 +114,25 @@
 	THREAD->last_cycle = get_cycle();
 
-	/* this is where each thread wakes up after its creation */
+	/* This is where each thread wakes up after its creation */
 	spinlock_unlock(&THREAD->lock);
 	interrupts_enable();
 
 	f(arg);
+	
+	/* Accumulate accounting to the task */
+	ipl_t ipl = interrupts_disable();
+	
+	spinlock_lock(&THREAD->lock);
+	thread_update_accounting();
+	uint64_t cycles = THREAD->cycles;
+	THREAD->cycles = 0;
+	spinlock_unlock(&THREAD->lock);
+	
+	spinlock_lock(&TASK->lock);
+	TASK->cycles += cycles;
+	spinlock_unlock(&TASK->lock);
+	
+	interrupts_restore(ipl);
+	
 	thread_exit();
 	/* not reached */
@@ -534,5 +550,5 @@
 	spinlock_lock(&threads_lock);
 	
-	printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kst        wq\n");
+	printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kstack     waitqueue\n");
 	printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
 
@@ -604,6 +620,4 @@
  * interrupts must be already disabled.
  *
- * @param t Pointer to thread.
- *
  */
 void thread_update_accounting(void)
