Index: kernel/generic/include/ps/ps.h
===================================================================
--- kernel/generic/include/ps/ps.h	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ kernel/generic/include/ps/ps.h	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -42,5 +42,5 @@
 extern size_t sys_ps_get_tasks(task_id_t *uspace_ids, size_t size);
 extern int sys_ps_get_task_info(task_id_t *uspace_id, task_info_t *uspace_info);
-extern int sys_ps_get_threads(task_id_t *uspace_id, thread_info_t *uspace_infos, size_t size);
+extern int sys_ps_get_threads(thread_info_t *uspace_infos, size_t size);
 extern int sys_ps_get_cpu_info(uspace_cpu_info_t *uspace_cpu);
 extern int sys_ps_get_mem_info(uspace_mem_info_t *mem_info);
Index: kernel/generic/include/ps/taskinfo.h
===================================================================
--- kernel/generic/include/ps/taskinfo.h	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ kernel/generic/include/ps/taskinfo.h	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -74,4 +74,5 @@
 typedef struct {
 	thread_id_t tid;
+	task_id_t taskid;
 	state_t state;
 	int priority;
Index: kernel/generic/src/ps/ps.c
===================================================================
--- kernel/generic/src/ps/ps.c	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ kernel/generic/src/ps/ps.c	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -48,5 +48,4 @@
 static size_t count;
 static size_t max_count;
-static task_t *selected_task;
 
 #define WRITE_TASK_ID(dst, i, src) copy_to_uspace(dst + i, src, sizeof(task_id_t))
@@ -163,9 +162,4 @@
 	spinlock_lock(&t->lock);
 
-	if (t->task != selected_task) {
-		spinlock_unlock(&t->lock);
-		return true;
-	}
-
 	++count;
 	if (count > max_count) {
@@ -175,4 +169,6 @@
 	
 	result.tid = t->tid;
+	ASSERT(t->task);
+	result.taskid = t->task->taskid;
 	result.state = t->state;
 	result.priority = t->priority;
@@ -191,19 +187,10 @@
 }
 
-int sys_ps_get_threads(task_id_t *uspace_id, thread_info_t *uspace_infos, size_t size)
+int sys_ps_get_threads(thread_info_t *uspace_infos, size_t size)
 {
 	ipl_t ipl;
 	ipl = interrupts_disable();
 
-	task_id_t id;
-	copy_from_uspace(&id, uspace_id, sizeof(task_id_t));
-	spinlock_lock(&tasks_lock);
-	selected_task = task_find_by_id(id);
-	spinlock_unlock(&tasks_lock);
-
-	if (!selected_task) {
-		return 0;
-	}
-
+	printf("LIst threads, size: %llu\n", size);
 	spinlock_lock(&threads_lock);
 
Index: uspace/app/ps/ps.c
===================================================================
--- uspace/app/ps/ps.c	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ uspace/app/ps/ps.c	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -99,10 +99,10 @@
 	int thread_count = THREAD_COUNT;
 	thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t));
-	int result = get_task_threads(taskid, threads, sizeof(thread_info_t) * thread_count);
+	int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
 
 	while (result > thread_count) {
 		thread_count *= 2;
 		threads = realloc(threads, thread_count * sizeof(thread_info_t));
-		result = get_task_threads(taskid, threads, sizeof(thread_info_t) * thread_count);
+		result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
 	}
 
@@ -115,4 +115,7 @@
 	printf("    ID    State  CPU   Prio    [k]uCycles    [k]kcycles   Cycle fault\n");
 	for (i = 0; i < result; ++i) {
+		if (threads[i].taskid != taskid) {
+			continue;
+		}
 		uint64_t ucycles, kcycles;
 		char usuffix, ksuffix;
Index: uspace/app/top/ps.c
===================================================================
--- uspace/app/top/ps.c	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ uspace/app/top/ps.c	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -86,10 +86,10 @@
 	int thread_count = THREAD_COUNT;
 	thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t));
-	int result = get_task_threads(taskid, threads, sizeof(thread_info_t) * thread_count);
+	int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
 
 	while (result > thread_count) {
 		thread_count *= 2;
 		threads = realloc(threads, thread_count * sizeof(thread_info_t));
-		result = get_task_threads(taskid, threads, sizeof(thread_info_t) * thread_count);
+		result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
 	}
 	
Index: uspace/lib/c/generic/ps.c
===================================================================
--- uspace/lib/c/generic/ps.c	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ uspace/lib/c/generic/ps.c	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -74,8 +74,7 @@
  *
  */
-int get_task_threads(task_id_t taskid, thread_info_t *infos, size_t size)
+int get_task_threads(thread_info_t *infos, size_t size)
 {
-	return __SYSCALL3(SYS_PS_GET_THREADS, (sysarg_t) &taskid, (sysarg_t) infos,
-			(sysarg_t) size);
+	return __SYSCALL2(SYS_PS_GET_THREADS, (sysarg_t) infos, (sysarg_t) size);
 }
 
Index: uspace/lib/c/include/ps.h
===================================================================
--- uspace/lib/c/include/ps.h	(revision a325832e40265e1eb176995bec5cf79d579eb46c)
+++ uspace/lib/c/include/ps.h	(revision faf38b24fb042fe9f1d90d5bb4cc3c9364782df0)
@@ -45,5 +45,5 @@
 extern size_t get_task_ids(task_id_t *ids, size_t size);
 extern int get_task_info(task_id_t id, task_info_t *info);
-extern int get_task_threads(task_id_t taskid, thread_info_t *infos, size_t size);
+extern int get_task_threads(thread_info_t *infos, size_t size);
 
 #endif
