Skip to content

Commit

Permalink
Move scheduling functionality into task; add Scheduler policy tra…
Browse files Browse the repository at this point in the history
…it (#1035)

* Add the `Scheduler` trait, which represents a scheduler policy.
  * By default, there is one instance of a `Scheduler` policy per CPU.
  * Support dynamically registering and switching between
    different scheduler policies on a per-CPU basis.
  * Because this is now defined in the `task` crate instead of in the
    `scheduler` crate, the `task` crate can now access all functionality
    provided by a scheduler policy, which allows for custom actions
    like setting priority or removing/adding blocked/unblocked tasks
    to/from a runqueue.

* Combine `runqueue_*` crates with their respective  and `scheduler_*` crates,
  which is an improved design because external crates should not be able to
  view or modify a scheduler policy's internal runqueue contents.
  * This design makes sense, and also prevents issues like #1000.

* Modify most applications that access runqueues via the old `runqueue_*`
  crate APIs to go through the new `Scheduler` API instead.

----------
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
Co-authored-by: Kevin Boos <kevinaboos@gmail.com>
  • Loading branch information
tsoutsman committed Oct 3, 2023
1 parent 0bd4447 commit 810e12f
Show file tree
Hide file tree
Showing 45 changed files with 776 additions and 1,717 deletions.
88 changes: 6 additions & 82 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions applications/bm/Cargo.toml
Expand Up @@ -33,9 +33,6 @@ path = "../../kernel/spawn"
[dependencies.path]
path = "../../kernel/path"

[dependencies.runqueue]
path = "../../kernel/runqueue"

[dependencies.heapfile]
path = "../../kernel/heapfile"
# [dependencies.application_main_fn]
Expand Down
1 change: 0 additions & 1 deletion applications/bm/src/lib.rs
Expand Up @@ -18,7 +18,6 @@ extern crate apic;
extern crate cpu;
extern crate spawn;
extern crate path;
extern crate runqueue;
extern crate heapfile;
extern crate scheduler;
extern crate libtest;
Expand Down
3 changes: 0 additions & 3 deletions applications/heap_eval/Cargo.toml
Expand Up @@ -23,9 +23,6 @@ path = "../../kernel/apic"
[dependencies.cpu]
path = "../../kernel/cpu"

[dependencies.runqueue]
path = "../../kernel/runqueue"

[dependencies.hashbrown]
version = "0.11.2"
features = ["nightly"]
Expand Down
1 change: 0 additions & 1 deletion applications/heap_eval/src/lib.rs
Expand Up @@ -7,7 +7,6 @@ extern crate hpet;
extern crate hashbrown;
extern crate qp_trie;
extern crate apic;
extern crate runqueue;
extern crate libtest;
extern crate spawn;
extern crate cpu;
Expand Down
3 changes: 0 additions & 3 deletions applications/kill/Cargo.toml
Expand Up @@ -15,8 +15,5 @@ path = "../../kernel/app_io"
[dependencies.task]
path = "../../kernel/task"

[dependencies.runqueue]
path = "../../kernel/runqueue"

# [dependencies.application_main_fn]
# path = "../../compiler_plugins"
1 change: 0 additions & 1 deletion applications/kill/src/lib.rs
Expand Up @@ -4,7 +4,6 @@ extern crate alloc;
// #[macro_use] extern crate debugit;

extern crate task;
extern crate runqueue;
extern crate getopts;

use getopts::Options;
Expand Down
2 changes: 1 addition & 1 deletion applications/ps/src/lib.rs
Expand Up @@ -60,7 +60,7 @@ pub fn main(args: Vec<String>) -> isize {
else {" "} ;

#[cfg(any(epoch_scheduler, priority_scheduler))] {
let priority = scheduler::get_priority(&task).map(|priority| format!("{}", priority)).unwrap_or_else(|| String::from("-"));
let priority = scheduler::priority(&task).map(|priority| format!("{}", priority)).unwrap_or_else(|| String::from("-"));
task_string.push_str(
&format!("{0:<5} {1:<10} {2:<4} {3:<4} {4:<5} {5:<10} {6}\n",
id, runstate, cpu, pinned, task_type, priority, task.name)
Expand Down
8 changes: 3 additions & 5 deletions applications/rq/Cargo.toml
Expand Up @@ -2,21 +2,19 @@
name = "rq"
version = "0.1.0"
authors = ["Christine Wang <chrissywang54@gmail.com>"]
edition = "2021"

[dependencies]
getopts = "0.2.21"

[dependencies.app_io]
path = "../../kernel/app_io"

[dependencies.apic]
path = "../../kernel/apic"
[dependencies.cpu]
path = "../../kernel/cpu"

[dependencies.task]
path = "../../kernel/task"

[dependencies.runqueue]
path = "../../kernel/runqueue"

# [dependencies.application_main_fn]
# path = "../../compiler_plugins"

0 comments on commit 810e12f

Please sign in to comment.