Skip to content

Commit c4d4de6

Browse files
committed
Use _sched_block_dequeue() helper in mutex_block_atomic()
Previously, mutex_block_atomic() only marked the running task as TASK_BLOCKED, which was sufficient when scheduling selected tasks by scanning the global task list. Since the new scheduler is designed to select only runnable tasks from ready_queue[], mutex blocking now also requires removing the task’s rq_node from the corresponding ready queue, preventing the scheduler from selecting a blocked (non-runnable/dequeued) task again.
1 parent b66b154 commit c4d4de6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/mutex.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ static void mutex_block_atomic(list_t *waiters)
7676
/* Add to waiters list */
7777
if (unlikely(!list_pushback(waiters, self)))
7878
panic(ERR_SEM_OPERATION);
79-
79+
8080
/* Block and yield atomically */
8181
self->state = TASK_BLOCKED;
82+
83+
/* Explicit remove list node from the ready queue */
84+
_sched_block_dequeue(self);
8285
_yield(); /* This releases NOSCHED when we context switch */
8386
}
8487

0 commit comments

Comments
 (0)