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

Function main

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

Source from the content-addressed store, hash-verified

29
30#[no_mangle]
31pub fn main(argc: usize, argv: &[&str]) -> i32 {
32 assert_eq!(argc, 2, "wrong argument");
33 let size_mb = 1usize;
34 let size_kb = size_mb << 10;
35 let workers = argv[1].parse::<usize>().expect("wrong argument");
36 assert!(workers >= 1 && size_kb % workers == 0, "wrong argument");
37
38 let start = get_time();
39
40 let mut v = Vec::new();
41 let size_mb = 1usize;
42 for _ in 0..workers {
43 v.push(thread_create(worker as usize, size_kb / workers));
44 }
45 for tid in v.iter() {
46 assert_eq!(0, waittid(*tid as usize));
47 }
48
49 let time_ms = (get_time() - start) as usize;
50 let speed_kbs = size_kb * 1000 / time_ms;
51 println!(
52 "{}MiB written by {} threads, time cost = {}ms, write speed = {}KiB/s",
53 size_mb, workers, time_ms, speed_kbs
54 );
55 0
56}

Callers

nothing calls this directly

Calls 3

thread_createFunction · 0.85
get_timeFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected