- if (!initialized)
- return;
- list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node)
- unregister_task(t);
- list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node)
- unregister_task(t);
- initialized = 0;
+ assert(info->post_select);
+
+ if (!s->task_list.next)
+ INIT_LIST_HEAD(&s->task_list);
+
+ snprintf(t->status, sizeof(t->status) - 1, "%s", info->name);
+ t->status[sizeof(t->status) - 1] = '\0';
+ t->notification = 0;
+ t->error = 0;
+ t->dead = false;
+ t->pre_select = info->pre_select;
+ t->post_select = info->post_select;
+ t->context = info->context;
+ t->owned_by_sched = true;
+ 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)
+{
+ assert(t->owned_by_sched);
+ return t->context;