diff options
| author | Tianhao Wang <shrik3@mailbox.org> | 2024-06-11 03:42:01 +0200 |
|---|---|---|
| committer | Tianhao Wang <shrik3@mailbox.org> | 2024-06-11 15:17:15 +0200 |
| commit | e148a5e329add10452d86ae8f2da97e545b7ecb2 (patch) | |
| tree | 707a9f0324155f7b4a77508afa7dbd2fccb9d500 | |
| parent | 0609a75bb016453cd7bb4f8393c31c572d56a06e (diff) | |
chore: cleanup sched code
| -rw-r--r-- | src/proc/sched.rs | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/proc/sched.rs b/src/proc/sched.rs index 0bb155d..613336e 100644 --- a/src/proc/sched.rs +++ b/src/proc/sched.rs @@ -43,28 +43,24 @@ impl Scheduler { panic!("scheduler lock has been taken, something wrong"); } let mut lock_guard = SCHEDULER.lock(); - let t = lock_guard.run_queue.pop_front(); - match t { - None => { - panic!("run queue empty, how? what do I do??") - } - Some(next_tid) => { - let next_task = next_tid.get_task_ref_mut(); - let me = Task::current().unwrap(); - lock_guard.run_queue.push_back(next_tid); - if me.pid == next_task.pid { - return; - } - // make sure we release the scheduler lock before doing context - // swap - drop(lock_guard); - unsafe { - context_swap( - &(me.context) as *const _ as u64, - &(next_task.context) as *const _ as u64, - ); - } - } + let next_tid = lock_guard + .run_queue + .pop_front() + .expect("empty run queue, how?"); + let next_task = next_tid.get_task_ref_mut(); + let me = Task::current().unwrap(); + lock_guard.run_queue.push_back(next_tid); + if me.pid == next_task.pid { + return; + } + // make sure we release the scheduler lock before doing context + // swap + drop(lock_guard); + unsafe { + context_swap( + &(me.context) as *const _ as u64, + &(next_task.context) as *const _ as u64, + ); } } |
