Commit 2957225
committed
Implement sched_dequeue_task() to dequeue task from ready queue
Previously, mo_task_dequeue() was only a stub and returned immediately
without performing any operation. As a result, tasks remained in the
ready queue after being dequeued, leading to potential scheduler
inconsistencies.
This change implements the full dequeue process:
- Searches for the task node in the ready queue by task ID.
- Maintains RR cursor consistency: the RR cursor should always point
to a valid task node in the ready queue. When removing a task node,
the cursor is advanced circularly to the next node.
- Unlinks the task node using list_unlink(), which removes the node
from the ready queue without freeing it. list_unlink() is used
instead of list_remove() to avoid accidentally freeing
kcb->task_current when the current running task is dequeued.
- Updates and checks queue_counts: if the ready queue becomes empty,
the RR cursor is set to NULL and the bitmap is cleared until a new
task is enqueued.1 parent 75b4eeb commit 2957225
1 file changed
+25
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
390 | | - | |
| 389 | + | |
| 390 | + | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
399 | 417 | | |
400 | 418 | | |
401 | 419 | | |
| |||
0 commit comments