Skip to content

Commit

Permalink
Device works
Browse files Browse the repository at this point in the history
  • Loading branch information
8176135 committed Jul 3, 2020
1 parent fa529ad commit 9ed5e67
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
25 changes: 19 additions & 6 deletions src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ pub fn os_start() {
os_create(234, SchedulingLevel::Periodic, 3, *&test_app).unwrap();
os_create(345, SchedulingLevel::Periodic, 2, *&test_app).unwrap();
os_create(456, SchedulingLevel::Periodic, 1, *&test_app).unwrap();
os_create(999, SchedulingLevel::Sporadic, 1, *&test_app_spor).unwrap();
os_create(9990, SchedulingLevel::Sporadic, 1, *&test_app_spor).unwrap();
os_create(9991, SchedulingLevel::Sporadic, 2, *&test_app_spor).unwrap();
os_create(9992, SchedulingLevel::Sporadic, 3, *&test_app_spor).unwrap();
os_create(9993, SchedulingLevel::Sporadic, 4, *&test_app_spor).unwrap();
os_create(415, SchedulingLevel::Device, 10, *&test_app_device).unwrap();
os_create(416, SchedulingLevel::Device, 15, *&test_app_device).unwrap();
// os_create(456, Periodic, 1, *&test_app).unwrap();
// tester(1);
}
Expand Down Expand Up @@ -109,15 +114,23 @@ extern "C" fn test_app() {

extern "C" fn test_app_spor() {
let mut a: i64 = 0;
for i in 0..5000000 {
let param = os_getparam();
for i in 0..10000000 {
if i % 1000000 == 0 {
println!("SPORE!!!");
println!("SPORE!!! {}", param);
os_yield();
}
a.wrapping_add(i);
}
println!("Primo Victoria: {} {}", os_getparam(), a);
os_yield();
println!("UNYIELDED!! {}", interrupts::are_enabled());
os_create(param + 4, SchedulingLevel::Sporadic, 123, test_app_spor);
println!("WE OUT!! {}", param);
}

extern "C" fn test_app_device() {
for i in 0..200 {
println!("Reminder for stuff from {} {} ", os_getparam(), i);
os_yield();
}
}

pub fn os_abort() {
Expand Down
8 changes: 6 additions & 2 deletions src/processes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ProcessesManager {
processes_list: vec![None; 2],
currently_executing_process: 0,
idle_process: Process::idle(),
scheduler: Scheduler::new(vec![(1, 10), (2, 5), (3, 5), (1, 5), (2, 10), (4, 5)]),
scheduler: Scheduler::new(vec![(1, 10), (2, 5), (3, 5), (1, 5), (2, 10), (4, 2)]),
pid_pool: IncrementingPool::new(1),
name_registry: DynamicBitmap::new(),
}
Expand Down Expand Up @@ -289,7 +289,11 @@ impl ProcessesManager {
}

fn get_process_mut_with_pid(&mut self, pid: Pid) -> Option<&mut Process> {
self.processes_list.get_mut(pid as usize - 1).and_then(|c| c.as_mut())
if pid == 0 {
Some(&mut self.idle_process)
} else {
self.processes_list.get_mut(pid as usize - 1).and_then(|c| c.as_mut())
}
}

fn get_process_with_pid(&self, pid: Pid) -> Option<&Process> {
Expand Down
4 changes: 2 additions & 2 deletions src/processes/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Process {

let terminate_ret_addr = os_terminate as usize;

println!("Function address: {:x}", program_start as *const () as usize);
// println!("Function address: {:x}", program_start as *const () as usize);
let fake_int_sp = x86_64::instructions::interrupts::without_interrupts(|| {
unsafe {
asm_fake_register(stack_bounds.end().as_u64() as usize,
Expand All @@ -52,7 +52,7 @@ impl Process {
}
});

println!("Fake stack point: {} {} {:x}", name, pid, fake_int_sp);
// println!("Fake stack point: {} {} {:x}", name, pid, fake_int_sp);
Process {
pid,
level,
Expand Down
2 changes: 1 addition & 1 deletion src/processes/scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Scheduler {

fn increment_periodic_index(&mut self) {
self.periodic_index = (self.periodic_index + 1) % self.periodic_order.len();
println!("Incremented Index: {}", self.periodic_index);
// println!("Incremented Index: {}", self.periodic_index);
}

pub fn get_current_periodic_entry(&self) -> (Name, usize) {
Expand Down

0 comments on commit 9ed5e67

Please sign in to comment.