static int __init make_init_task() { extern void idle(); /* becomes init task */ /* stack must be allocated first. and to build root relationship * properly `current` must be set to `init`. */ current = &init; if (alloc_mm(&init, NULL, 0)) return -ERR_ALLOC; set_task_dressed(&init, TASK_STATIC | TASK_KERNEL, idle); set_task_context_hard(&init, wrapper); set_task_pri(&init, LOW_PRIORITY); set_task_state(&init, TASK_RUNNING); /* make it the sole */ list_link_init(&init.children); list_link_init(&init.sibling); return 0; }
void set_task_context(struct task *p, void *addr) { set_task_context_hard(p, addr); set_task_context_soft(p); }