Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 88dea9d01a9bc5e8482c1ceafa6e6531ac50cb4f)
+++ kernel/generic/src/proc/task.c	(revision e1b674201c97668fa9f3559cca094e0e1865629a)
@@ -312,12 +312,11 @@
  * @param id Task ID.
  *
- * @return Task structure address or NULL if there is no such task
- *         ID.
+ * @return Task structure address or NULL if there is no such task ID.
  *
  */
 task_t *task_find_by_id(task_id_t id)
 {
-	avltree_node_t *node;
-	node = avltree_search(&tasks_tree, (avltree_key_t) id);
+	avltree_node_t *node =
+	    avltree_search(&tasks_tree, (avltree_key_t) id);
 	
 	if (node)
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 88dea9d01a9bc5e8482c1ceafa6e6531ac50cb4f)
+++ kernel/generic/src/proc/thread.c	(revision e1b674201c97668fa9f3559cca094e0e1865629a)
@@ -84,5 +84,10 @@
 	"Exiting",
 	"Lingering"
-}; 
+};
+
+typedef struct {
+	thread_id_t thread_id;
+	thread_t *thread;
+} thread_iterator_t;
 
 /** Lock protecting the threads_tree AVL tree.
@@ -726,4 +731,41 @@
 	THREAD->last_cycle = time;
 }
+
+static bool thread_search_walker(avltree_node_t *node, void *arg)
+{
+	thread_t *thread =
+	    (thread_t *) avltree_get_instance(node, thread_t, threads_tree_node);
+	thread_iterator_t *iterator = (thread_iterator_t *) arg;
+	
+	if (thread->tid == iterator->thread_id) {
+		iterator->thread = thread;
+		return false;
+	}
+	
+	return true;
+}
+
+/** Find thread structure corresponding to thread ID.
+ *
+ * The threads_lock must be already held by the caller of this function and
+ * interrupts must be disabled.
+ *
+ * @param id Thread ID.
+ *
+ * @return Thread structure address or NULL if there is no such thread ID.
+ *
+ */
+thread_t *thread_find_by_id(thread_id_t thread_id)
+{
+	thread_iterator_t iterator;
+	
+	iterator.thread_id = thread_id;
+	iterator.thread = NULL;
+	
+	avltree_walk(&threads_tree, thread_search_walker, (void *) &iterator);
+	
+	return iterator.thread;
+}
+
 
 /** Process syscall to create new thread.
