Skip to content

Commit e31e079

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 7257b07 commit e31e079

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

704-
if (!kcb->task_current)
705-
kcb->task_current = kcb->harts->task_idle;
706-
707704
return;
708705
}
709706

@@ -769,10 +766,6 @@ int32_t mo_task_spawn(void *task_entry, uint16_t stack_size_req)
769766

770767
/* Push node to ready queue */
771768
sched_enqueue_task(tcb);
772-
if (!kcb->task_current) {
773-
kcb->task_current = kcb->harts->rr_cursors[tcb->prio_level];
774-
tcb->state = TASK_RUNNING;
775-
}
776769

777770
CRITICAL_LEAVE();
778771

0 commit comments

Comments
 (0)