os/syscall/
process.rs

1//! Process management syscalls
2use crate::task::{exit_current_and_run_next, suspend_current_and_run_next};
3use crate::timer::get_time_ms;
4
5/// task exits and submit an exit code
6pub fn sys_exit(exit_code: i32) -> ! {
7    println!("[kernel] Application exited with code {}", exit_code);
8    exit_current_and_run_next();
9    panic!("Unreachable in sys_exit!");
10}
11
12/// current task gives up resources for other tasks
13pub fn sys_yield() -> isize {
14    suspend_current_and_run_next();
15    0
16}
17
18/// get time in milliseconds
19pub fn sys_get_time() -> isize {
20    get_time_ms() as isize
21}