Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision ef1eab71c59f1782c6211550d5ee608250a791e0)
+++ kernel/generic/src/proc/task.c	(revision da75af41c10d3e964e96561840fd284f4c25c790)
@@ -107,5 +107,4 @@
 {
 	size_t tasks_left;
-	odlink_t *odlink;
 	task_t *task;
 
@@ -128,8 +127,6 @@
 		tasks_left = 0;
 
-		odlink = odict_first(&tasks);
-		while (odlink != NULL) {
-			task = odict_get_instance(odlink, task_t, ltasks);
-
+		task = task_first();
+		while (task != NULL) {
 			if (task != TASK) {
 				tasks_left++;
@@ -140,5 +137,5 @@
 			}
 
-			odlink = odict_next(odlink, &tasks);
+			task = task_next(task);
 		}
 
@@ -452,4 +449,53 @@
 }
 
+/** Get count of tasks.
+ *
+ * @return Number of tasks in the system
+ */
+size_t task_count(void)
+{
+	assert(interrupts_disabled());
+	assert(irq_spinlock_locked(&tasks_lock));
+
+	return odict_count(&tasks);
+}
+
+/** Get first task (task with lowest ID).
+ *
+ * @return Pointer to first task or @c NULL if there are none.
+ */
+task_t *task_first(void)
+{
+	odlink_t *odlink;
+
+	assert(interrupts_disabled());
+	assert(irq_spinlock_locked(&tasks_lock));
+
+	odlink = odict_first(&tasks);
+	if (odlink == NULL)
+		return NULL;
+
+	return odict_get_instance(odlink, task_t, ltasks);
+}
+
+/** Get next task (with higher task ID).
+ *
+ * @param cur Current task
+ * @return Pointer to next task or @c NULL if there are no more tasks.
+ */
+task_t *task_next(task_t *cur)
+{
+	odlink_t *odlink;
+
+	assert(interrupts_disabled());
+	assert(irq_spinlock_locked(&tasks_lock));
+
+	odlink = odict_next(&cur->ltasks, &tasks);
+	if (odlink == NULL)
+		return NULL;
+
+	return odict_get_instance(odlink, task_t, ltasks);
+}
+
 /** Get accounting data of given task.
  *
@@ -658,12 +704,10 @@
 #endif
 
-	odlink_t *odlink;
 	task_t *task;
 
-	odlink = odict_first(&tasks);
-	while (odlink != NULL) {
-		task = odict_get_instance(odlink, task_t, ltasks);
+	task = task_first();
+	while (task != NULL) {
 		task_print(task, additional);
-		odlink = odict_next(odlink, &tasks);
+		task = task_next(task);
 	}
 
