Skip to content

Commit bcbac6b

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 265b1be commit bcbac6b

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
@@ -429,20 +429,16 @@ void sched_tick_current_task(void)
429429
}
430430
}
431431

432-
/* Task wakeup - simple state transition approach */
432+
/* Task wakeup and enqueue into ready queue */
433433
void sched_wakeup_task(tcb_t *task)
434434
{
435435
if (unlikely(!task))
436436
return;
437437

438-
/* Mark task as ready - scheduler will find it during round-robin traversal
438+
/* Enqueue task into ready queue for scheduler selection by rr_cursor.
439439
*/
440-
if (task->state != TASK_READY) {
441-
task->state = TASK_READY;
442-
/* Ensure task has time slice */
443-
if (task->time_slice == 0)
444-
task->time_slice = get_priority_timeslice(task->prio_level);
445-
}
440+
if (task->state != TASK_READY && task->state != TASK_RUNNING)
441+
sched_enqueue_task(task);
446442
}
447443

448444
/* Efficient Round-Robin Task Selection (Cursor-Based, O(1) Complexity)

0 commit comments

Comments
 (0)