Skip to content

Commit e04881d

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 41df658 commit e04881d

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

709-
if (!kcb->task_current)
710-
kcb->task_current = kcb->harts->task_idle;
711-
712709
return;
713710
}
714711

@@ -774,10 +771,6 @@ int32_t mo_task_spawn(void *task_entry, uint16_t stack_size_req)
774771

775772
/* Push node to ready queue */
776773
sched_enqueue_task(tcb);
777-
if (!kcb->task_current) {
778-
kcb->task_current = kcb->harts->rr_cursors[tcb->prio_level];
779-
tcb->state = TASK_RUNNING;
780-
}
781774

782775
CRITICAL_LEAVE();
783776

0 commit comments

Comments
 (0)