Skip to content

Commit 10e1e89

Browse files
committed
Add enqueuing path in semaphore and mutex
This commit adds the missing enqueuing path for awakened tasks during semaphore signaling and mutex unlocking, ensuring that tasks are correctly inserted into the ready queue under the new scheduler design.
1 parent 09f45dd commit 10e1e89

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

include/sys/task.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,6 @@ void _sched_block(queue_t *wait_q);
312312
* Returns 'true' to enable preemptive scheduling, or 'false' for cooperative
313313
*/
314314
int32_t app_main(void);
315+
316+
/* Wake up and enqueue task into ready queue */
317+
void sched_wakeup_task(tcb_t *);

kernel/mutex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ int32_t mo_mutex_unlock(mutex_t *m)
283283
/* Validate task state before waking */
284284
if (likely(next_owner->state == TASK_BLOCKED)) {
285285
m->owner_tid = next_owner->id;
286-
next_owner->state = TASK_READY;
286+
sched_wakeup_task(next_owner);
287287
/* Clear any pending timeout since we're granting ownership */
288288
next_owner->delay = 0;
289289
} else {

kernel/semaphore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void mo_sem_signal(sem_t *s)
176176
if (likely(awakened_task)) {
177177
/* Validate awakened task state consistency */
178178
if (likely(awakened_task->state == TASK_BLOCKED)) {
179-
awakened_task->state = TASK_READY;
179+
sched_wakeup_task(awakened_task);
180180
should_yield = true;
181181
} else {
182182
/* Task state inconsistency - this should not happen */

0 commit comments

Comments
 (0)