-
Notifications
You must be signed in to change notification settings - Fork 20
feat(executor): added async task #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces an async task executor to the axtask module, enabling asynchronous task execution alongside the existing synchronous task system. The implementation adds a global ready queue for async tasks with spawn, polling, and execution control functions.
Key changes:
- New async executor module with task spawning and execution control (
run_once,run_for,run_until_idle) - Integration with existing
block_onto drive executor tasks during synchronous future polling - Comprehensive test coverage for executor fairness, self-wake, and execution control
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/axtask/src/executor.rs | New async executor implementation with ready queue, AsyncTask wrapper, and execution control functions |
| modules/axtask/src/lib.rs | Adds executor module to the crate's public API |
| modules/axtask/src/api.rs | Initializes executor during scheduler initialization |
| modules/axtask/src/task.rs | Changes TaskId::new() visibility from private to pub(crate) for executor use |
| modules/axtask/src/future/mod.rs | Integrates executor into block_on by polling up to 3 async tasks per iteration |
| modules/axtask/src/tests.rs | Adds comprehensive test suite for executor functionality including completion, self-wake, fairness, and run_for tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Good job 👍 |
What should be the focus of the next optimization? Scaling the async task queue to per-CPU, or optimizing the Waker implementation? |
7891b07 to
de8ea45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/axtask/src/future/mod.rs
Outdated
| // Polling the executor to run up to three async tasks | ||
| // (may run fewer if the queue has fewer ready tasks). | ||
| let _ = executor::run_for(3); |
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 3 for max async tasks to run is unexplained. Consider extracting this as a named constant (e.g., MAX_ASYNC_TASKS_PER_POLL) to clarify why this specific value was chosen and make it easier to tune if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
806ca9d to
290b4a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub fn find_area(&self, vaddr: VirtAddr) -> Option<&MemoryArea<Backend>> { | ||
| self.areas.find(vaddr) | ||
| } |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new find_area method is identical to the existing find_area_mut method on line 113 (which also calls self.areas.find(vaddr)). The only difference is that find_area_mut returns a mutable reference. This creates duplicate logic. Consider whether this new method is necessary, or if callers should use find_area_mut and simply not mutate the result.
| READY_QUEUE.with_current(|q| q.is_empty()) | ||
| } | ||
|
|
||
| pub fn run_until_idle() { |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 64 for SPIN_LIMIT lacks explanation. Consider adding a comment explaining why this specific value was chosen and what trade-offs it represents between spinning and yielding.
| pub fn run_until_idle() { | |
| pub fn run_until_idle() { | |
| // Number of consecutive spin iterations before yielding the CPU. | |
| // 64 is a small power-of-two chosen as a compromise: it allows short-lived | |
| // bursts of wakeups to be handled without an expensive scheduler yield, | |
| // while still bounding the time spent busy-waiting when the system is idle. |
Per-CPU Async Architecture
Optimized
|
No description provided.