finish comment of sync

master
chenqiuhao 6 years ago
parent 96c79520cf
commit c4b53dc8e5

@ -1,3 +1,5 @@
//! entrance to test the communication in processes with solving five philosophers problem
mod mutex; mod mutex;
mod monitor; mod monitor;

@ -1,3 +1,5 @@
//! solve the five philosophers problem with monitor
use std::thread; use std::thread;
use std::sync::{Mutex, Condvar, Arc}; use std::sync::{Mutex, Condvar, Arc};
use std::time::Duration; use std::time::Duration;
@ -51,6 +53,7 @@ struct Table {
fork_condvar: Vec<Condvar>, fork_condvar: Vec<Condvar>,
} }
// the main function to test
pub fn main() { pub fn main() {
let table = Arc::new(Table { let table = Arc::new(Table {
fork_status: Mutex::new(vec![false; 5]), fork_status: Mutex::new(vec![false; 5]),

@ -1,3 +1,5 @@
//! solve the five philosophers problem with mutex
use std::thread; use std::thread;
use std::sync::{Mutex, Arc}; use std::sync::{Mutex, Arc};
use std::time::Duration; use std::time::Duration;
@ -35,6 +37,7 @@ struct Table {
forks: Vec<Mutex<()>>, forks: Vec<Mutex<()>>,
} }
// the main function to test
pub fn main() { pub fn main() {
let table = Arc::new(Table { let table = Arc::new(Table {
forks: vec![ forks: vec![

Loading…
Cancel
Save