+/**
+ * Add a task to the scheduler task list.
+ *
+ * \param info Task information supplied by the caller.
+ * \param s The scheduler instance.
+ *
+ * \return A pointer to a newly allocated task structure. It will be
+ * freed by sched_shutdown().
+ */
+struct task *task_register(struct task_info *info, struct sched *s)
+{
+ struct task *t = para_malloc(sizeof(*t));
+
+ assert(info->post_select);
+
+ if (!s->task_list.next)
+ INIT_LIST_HEAD(&s->task_list);
+
+ t->info = *info;
+ t->name = para_strdup(info->name);
+ t->notification = 0;
+ t->status = TS_RUNNING;
+ list_add_tail(&t->node, &s->task_list);
+ return t;
+}
+
+/**
+ * Obtain the context pointer of a task.
+ *
+ * \param t Return this task's context pointer.
+ *
+ * \return A pointer to the memory location specified previously as \a
+ * task_info->context when the task was registered with \ref task_register().
+ */
+void *task_context(struct task *t)
+{
+ return t->info.context;
+}
+