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

Function worker

user/src/bin/huge_write_mt.rs:12–28  ·  view source on GitHub ↗
(size_kib: usize)

Source from the content-addressed store, hash-verified

10use user_lib::{exit, thread_create, waittid};
11
12fn worker(size_kib: usize) {
13 let mut buffer = [0u8; 1024]; // 1KiB
14 for (i, ch) in buffer.iter_mut().enumerate() {
15 *ch = i as u8;
16 }
17 let filename = format(format_args!("testf{}\0", gettid()));
18 let f = open(filename.as_str(), OpenFlags::CREATE | OpenFlags::WRONLY);
19 if f < 0 {
20 panic!("Open test file failed!");
21 }
22 let f = f as usize;
23 for _ in 0..size_kib {
24 write(f, &buffer);
25 }
26 close(f);
27 exit(0)
28}
29
30#[no_mangle]
31pub fn main(argc: usize, argv: &[&str]) -> i32 {

Callers

nothing calls this directly

Calls 4

openFunction · 0.85
writeFunction · 0.85
closeFunction · 0.85
exitFunction · 0.85

Tested by

no test coverage detected