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

Function main

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

Source from the content-addressed store, hash-verified

28
29#[no_mangle]
30pub fn main(argc: usize, argv: &[&str]) -> i32 {
31 let count: usize;
32 if argc == 1 {
33 count = THREAD_COUNT;
34 } else if argc == 2 {
35 count = argv[1].to_string().parse::<usize>().unwrap();
36 } else {
37 println!(
38 "ERROR in argv, argc is {}, argv[0] {} , argv[1] {} , argv[2] {}",
39 argc, argv[0], argv[1], argv[2]
40 );
41 exit(-1);
42 }
43
44 let start = get_time();
45 let mut v = Vec::new();
46 for _ in 0..THREAD_COUNT {
47 v.push(thread_create(f as usize, count) as usize);
48 }
49 let mut time_cost = Vec::new();
50 for tid in v.iter() {
51 time_cost.push(waittid(*tid));
52 }
53 println!("time cost is {}ms", get_time() - start);
54 assert_eq!(unsafe { A }, PER_THREAD * THREAD_COUNT);
55 0
56}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected