Skip to content

Commit 160bed5

Browse files
committed
Add ready queue enqueue path in mo_task_wakeup()
Previously, mo_task_wakeup() only changed the task state to TASK_READY without enqueuing the task back into the ready queue. As a result, a woken-up task could remain invisible to the scheduler and never be selected for execution. This change adds a call to sched_enqueue_task() to insert the task into the appropriate ready queue based on its priority level. The ready bitmap, task counts of each ready queue, and RR cursor are updated accordingly to maintain scheduler consistency. With this update, tasks transitioned from a blocked or suspended state can be properly scheduled for execution once they are woken up.
1 parent e813dd9 commit 160bed5

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

kernel/task.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,16 @@ void sched_tick_current_task(void)
434434
}
435435
}
436436

437-
/* Task wakeup - simple state transition approach */
437+
/* Task wakeup and enqueue into ready queue */
438438
void sched_wakeup_task(tcb_t *task)
439439
{
440440
if (unlikely(!task))
441441
return;
442442

443-
/* Mark task as ready - scheduler will find it during round-robin traversal
443+
/* Enqueue task into ready queue for scheduler selection by rr_cursor.
444444
*/
445-
if (task->state != TASK_READY) {
446-
task->state = TASK_READY;
447-
/* Ensure task has time slice */
448-
if (task->time_slice == 0)
449-
task->time_slice = get_priority_timeslice(task->prio_level);
450-
}
445+
if (task->state != TASK_READY && task->state != TASK_RUNNING)
446+
sched_enqueue_task(task);
451447
}
452448

453449
/* Efficient Round-Robin Task Selection with O(n) Complexity

0 commit comments

Comments
 (0)