Skip to content

Commit 31a8c73

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 f1b993b commit 31a8c73

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
@@ -721,9 +721,6 @@ void idle_task_init(void)
721721
printf("idle id %u: entry=%p stack=%p size=%u\n", idle->id, &sched_idle,
722722
idle->stack, (unsigned int) stack_size);
723723

724-
if (!kcb->task_current)
725-
kcb->task_current = kcb->harts->task_idle;
726-
727724
return;
728725
}
729726

@@ -789,10 +786,6 @@ int32_t mo_task_spawn(void *task_entry, uint16_t stack_size_req)
789786

790787
/* Push node to ready queue */
791788
sched_enqueue_task(tcb);
792-
if (!kcb->task_current) {
793-
kcb->task_current = kcb->harts->rr_cursors[tcb->prio_level];
794-
tcb->state = TASK_RUNNING;
795-
}
796789

797790
CRITICAL_LEAVE();
798791

0 commit comments

Comments
 (0)