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

Function thread_fn

user/src/bin/peterson.rs:49–66  ·  view source on GitHub ↗
(id: usize)

Source from the content-addressed store, hash-verified

47}
48
49pub fn thread_fn(id: usize) -> ! {
50 // println!("Thread[{}] init.", id);
51 let peer_id: usize = id ^ 1;
52 for iter in 0..N {
53 if iter % 10 == 0 {
54 println!("[{}] it={}", id, iter);
55 }
56 peterson_enter_critical(id, peer_id);
57 critical_test_enter();
58 for _ in 0..3 {
59 critical_test_claim();
60 sleep(2);
61 }
62 critical_test_exit();
63 peterson_exit_critical(id);
64 }
65 exit(0)
66}
67
68#[no_mangle]
69pub fn main() -> i32 {

Callers

nothing calls this directly

Calls 7

peterson_enter_criticalFunction · 0.85
sleepFunction · 0.85
peterson_exit_criticalFunction · 0.85
exitFunction · 0.85
critical_test_enterFunction · 0.70
critical_test_claimFunction · 0.70
critical_test_exitFunction · 0.70

Tested by

no test coverage detected