@ -176,7 +176,7 @@ impl<T: Context, S: Scheduler> Processor_<T, S> {
to.status = Status::Running;
self.scheduler.remove(pid);
info!("switch from {} to {} {:x?}", pid0, pid, to.context);
//info!("switch from {} to {} {:x?}", pid0, pid, to.context);
unsafe { from.context.switch(&mut to.context); }
}
@ -1,3 +1,5 @@
//! entrance to test the communication in processes with solving five philosophers problem
mod mutex;
mod monitor;
//! solve the five philosophers problem with monitor
use std::thread;
use std::sync::{Mutex, Condvar, Arc};
use std::time::Duration;
@ -51,6 +53,7 @@ struct Table {
fork_condvar: Vec<Condvar>,
// the main function to test
pub fn main() {
let table = Arc::new(Table {
fork_status: Mutex::new(vec![false; 5]),
//! solve the five philosophers problem with mutex
use std::sync::{Mutex, Arc};
@ -35,6 +37,7 @@ struct Table {
forks: Vec<Mutex<()>>,
forks: vec![