Improve dispatch to a real scheduler using preemption#117
Merged
LuernOutOfOrder merged 44 commits intodevelopfrom Feb 19, 2026
Merged
Improve dispatch to a real scheduler using preemption#117LuernOutOfOrder merged 44 commits intodevelopfrom
LuernOutOfOrder merged 44 commits intodevelopfrom
Conversation
…e for preemptive scheduling
…future use Also update the type of task max priority in config file
…e, add new task public API to get task's priority
…ture and use it in scheduler
…tive, add a new delta_list primitive and update in scheduler
… it and see if t's work(it doesn't)
…uch pain for not much gain
…s for the indexed_linked_list
…ocked queue, update task primitive as well The task primitive now use correctly the new blocked queue, they don't touch the queues directly, just trigger a reschedule if needed. The scheduler will check the blocked queue and awake the head if a need_reschedule has been trigger.
…tly update the current_task, also improve the need_resched flag use in scheduler
Preemptive scheduler working, there's an exception after few cycles, don't know why
…me keep running Still the low priority task restarting from 0.
…pdate trap entry to save the task context and restore it if there's no need reschedule Remove the mstatus save, risky in trap handling if mstatus change
…, fix task context to use correct mstatus value Task context mstatus has been update to use 6152 instead of 8 to enable M-mode on task,for now at least
Things are smelly, like if two task with different priority print, it can cause race condition and corrupt uart driver leading to a complete kernel crash(mcause = 7), but if the print or logging system is protected with a mutex, or while printing, we deactivate interrupt, there's no problem.
…ng mstatus from context routine
No runtime starting for now, execute the task manually
…eue and remove mstatus in task context
…es, remove unused import and variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to the kernel's scheduler and context switching mechanisms, adds new documentation, and refactors several core data structures. The most notable changes include a complete rewrite of the scheduler logic (including the introduction of run and blocked queues), the addition of a bitmap utility for efficient priority management, and a major refactor of context save/restore assembly routines. Documentation has also been expanded to describe new and existing data structures and scheduler behavior.
Kernel Scheduler and Task Queues:
src/config.rs, and updated documentation to reflect these changes. [1] [2]Data Structures and Utilities:
Bitmapstruct insrc/primitives/bitmap.rsto efficiently manage and query task priorities in the run queue.IndexedLinkedListdata structure and its invariants inDocumentation/kernel/data_structure.md. [1] [2]Context Switching and Trap Handling:
mstatusin the task context, rewrotesave_context/restore_contextto handle privilege and interrupt bits directly, and introducedtrap_save_context/trap_restore_contextfor trap entry/exit. [1] [2] [3] [4] [5] [6] [7] [8]TaskContextstruct in Rust to remove themstatusfield and adjust offsets accordingly. [1] [2]Miscellaneous and Documentation:
Cargo.tomlandsrc/info.rs. [1] [2]stmt_expr_attributesnightly feature insrc/main.rs.These changes collectively modernize the kernel's scheduling and context switching logic, improve documentation, and lay groundwork for further extensibility and debugging.