Skip to content

Commit 73ec272

Browse files
committed
Remove first-task binding from task initialization
Previously, both mo_task_spawn() and idle_task_init() implicitly bound their created tasks to kcb->task_current as the first execution context. This behavior caused ambiguity with the scheduler, which is now responsible for determining the active task during system startup. This change removes the initial binding logic from both functions, allowing the startup process (main()) to explicitly assign kcb->task_current (typically to the idle task) during launch. This ensures a single, centralized initialization flow and improves the separation between task creation and scheduling control.
1 parent e7da7fe commit 73ec272

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

kernel/task.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,6 @@ void idle_task_init(void)
695695
printf("idle id %u: entry=%p stack=%p size=%u\n", idle->id, &sched_idle,
696696
idle->stack, (unsigned int) stack_size);
697697

698-
if (!kcb->task_current)
699-
kcb->task_current = kcb->harts->task_idle;
700-
701698
return;
702699
}
703700

@@ -763,10 +760,6 @@ int32_t mo_task_spawn(void *task_entry, uint16_t stack_size_req)
763760

764761
/* Push node to ready queue */
765762
sched_enqueue_task(tcb);
766-
if (!kcb->task_current) {
767-
kcb->task_current = kcb->harts->rr_cursors[tcb->prio_level];
768-
tcb->state = TASK_RUNNING;
769-
}
770763

771764
CRITICAL_LEAVE();
772765

0 commit comments

Comments
 (0)