Index: generic/include/proc/task.h
===================================================================
--- generic/include/proc/task.h	(revision 016acbeda8dba3ce9de19be150961235e9a4d576)
+++ generic/include/proc/task.h	(revision 6a78e84e40c978ede6b0d1cb8b8020c35e98a4eb)
@@ -32,4 +32,5 @@
 #include <typedefs.h>
 #include <synch/spinlock.h>
+#include <adt/btree.h>
 #include <adt/list.h>
 #include <ipc/ipc.h>
@@ -40,7 +41,6 @@
 	char *name;
 	link_t th_head;		/**< List of threads contained in this task. */
-	link_t tasks_link;	/**< Link to other tasks within the system. */
 	as_t *as;		/**< Address space. */
-	task_id_t taskid;           /**< Unique identity of task */
+	task_id_t taskid;	/**< Unique identity of task */
 
 	/* IPC stuff */
@@ -51,5 +51,5 @@
 
 extern spinlock_t tasks_lock;
-extern link_t tasks_head;
+extern btree_t tasks_btree;
 
 extern void task_init(void);
Index: generic/src/proc/task.c
===================================================================
--- generic/src/proc/task.c	(revision 016acbeda8dba3ce9de19be150961235e9a4d576)
+++ generic/src/proc/task.c	(revision 6a78e84e40c978ede6b0d1cb8b8020c35e98a4eb)
@@ -36,4 +36,5 @@
 #include <arch.h>
 #include <panic.h>
+#include <adt/btree.h>
 #include <adt/list.h>
 #include <ipc/ipc.h>
@@ -43,5 +44,5 @@
 
 SPINLOCK_INITIALIZE(tasks_lock);
-LIST_INITIALIZE(tasks_head);
+btree_t tasks_btree;
 static task_id_t task_counter = 0;
 
@@ -54,4 +55,5 @@
 {
 	TASK = NULL;
+	btree_create(&tasks_btree);
 }
 
@@ -77,5 +79,4 @@
 	spinlock_initialize(&ta->lock, "task_ta_lock");
 	list_initialize(&ta->th_head);
-	list_initialize(&ta->tasks_link);
 	ta->as = as;
 	ta->name = name;
@@ -93,5 +94,5 @@
 
 	ta->taskid = ++task_counter;
-	list_append(&ta->tasks_link, &tasks_head);
+	btree_insert(&tasks_btree, (__native) ta, (void *) ta, NULL);
 
 	spinlock_unlock(&tasks_lock);
@@ -152,7 +153,5 @@
 {
 	link_t *cur;
-	task_t *t;
 	ipl_t ipl;
-	int i;
 	
 	/* Messing with thread structures, avoid deadlock */
@@ -160,15 +159,25 @@
 	spinlock_lock(&tasks_lock);
 
-	for (cur=tasks_head.next; cur!=&tasks_head; cur=cur->next) {
-		t = list_get_instance(cur, task_t, tasks_link);
-		spinlock_lock(&t->lock);
-		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)
-				printf(" Ph(%d): %P ", i,t->phones[i].callee);
+	for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
+		btree_node_t *node;
+		int i;
+		
+		node = list_get_instance(cur, btree_node_t, leaf_link);
+		for (i = 0; i < node->keys; i++) {
+			task_t *t;
+			int j;
+
+			t = (task_t *) node->value[i];
+		
+			spinlock_lock(&t->lock);
+			printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d",
+				t->name, t, t->taskid, t->as, atomic_get(&t->active_calls));
+			for (j=0; j < IPC_MAX_PHONES; j++) {
+				if (t->phones[j].callee)
+					printf(" Ph(%d): %P ", j, t->phones[j].callee);
+			}
+			printf("\n");
+			spinlock_unlock(&t->lock);
 		}
-		printf("\n");
-		spinlock_unlock(&t->lock);
 	}
 
