Merge recent update from ch7 && cargo clippy

This commit is contained in:
Yifan Wu 2022-01-22 12:32:36 -08:00
parent 737340b0a0
commit c9583b0f53
20 changed files with 236 additions and 163 deletions

View file

@ -9,7 +9,7 @@ extern crate alloc;
use user_lib::{semaphore_create, semaphore_up, semaphore_down};
use user_lib::{thread_create, waittid, sleep};
use user_lib::exit;
use alloc::vec::Vec;
use alloc::vec;
const SEM_SYNC: usize = 0;
@ -33,9 +33,10 @@ pub fn main() -> i32 {
// create semaphores
assert_eq!(semaphore_create(0) as usize, SEM_SYNC);
// create threads
let mut threads = Vec::new();
threads.push(thread_create(first as usize, 0));
threads.push(thread_create(second as usize, 0));
let threads = vec![
thread_create(first as usize, 0),
thread_create(second as usize, 0),
];
// wait for all threads to complete
for thread in threads.iter() {
waittid(*thread as usize);