1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-23 18:06:20 +04:00

Right now, we return a pointer by usize. This is not good programming in

Rust. Instead, the scheduler needs to be modified to return a process
structure's reference. Then, we can extract the fields and then switch.
However, this will require us to have to change how the PROCESS_LIST
works. Since it uses move constructs, we cannot move a process out of it
when we replace the process list.
This commit is contained in:
Stephen Marz 2020-03-12 13:55:11 -04:00
parent d9b1743698
commit 7b038cdc24

View File

@ -6,7 +6,7 @@
use crate::{cpu::{build_satp, SatpMode},
process::{ProcessState, PROCESS_LIST}};
pub fn schedule() -> (usize, usize, usize) {
pub fn schedule() -> (usize, usize) {
unsafe {
if let Some(mut pl) = PROCESS_LIST.take() {
pl.rotate_left(1);
@ -19,7 +19,6 @@ pub fn schedule() -> (usize, usize, usize) {
ProcessState::Running => {
frame_addr =
prc.get_frame_address();
mepc = prc.get_program_counter();
satp = prc.get_table_address();
pid = prc.get_pid() as usize;
},
@ -37,7 +36,6 @@ pub fn schedule() -> (usize, usize, usize) {
// processes.
if satp != 0 {
return (frame_addr,
mepc,
build_satp(
SatpMode::Sv39,
pid,
@ -45,10 +43,10 @@ pub fn schedule() -> (usize, usize, usize) {
));
}
else {
return (frame_addr, mepc, 0);
return (frame_addr, 0);
}
}
}
}
(0, 0, 0)
(0, 0)
}