MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / main

Function main

user/src/bin/adder_mutex_blocking.rs:36–59  ·  view source on GitHub ↗
(argc: usize, argv: &[&str])

Source from the content-addressed store, hash-verified

34
35#[no_mangle]
36pub fn main(argc: usize, argv: &[&str]) -> i32 {
37 let mut thread_count = THREAD_COUNT_DEFAULT;
38 let mut per_thread = PER_THREAD_DEFAULT;
39 if argc >= 2 {
40 thread_count = argv[1].parse().unwrap();
41 if argc >= 3 {
42 per_thread = argv[2].parse().unwrap();
43 }
44 }
45 unsafe { PER_THREAD = per_thread; }
46
47 let start = get_time();
48 assert_eq!(mutex_blocking_create(), 0);
49 let mut v = Vec::new();
50 for _ in 0..thread_count {
51 v.push(thread_create(f as usize, 0) as usize);
52 }
53 for tid in v.into_iter() {
54 waittid(tid);
55 }
56 println!("time cost is {}ms", get_time() - start);
57 assert_eq!(unsafe { A }, unsafe { PER_THREAD } * thread_count);
58 0
59}

Callers

nothing calls this directly

Calls 5

thread_createFunction · 0.85
waittidFunction · 0.85
get_timeFunction · 0.50
pushMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected