添加用户态系统调用sys_yield

ch3-coop
zhangxinyu 2 years ago
parent ee8f0b1945
commit b03f0340b7

@ -1,10 +1,7 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::yield_;
use user_lib::{syscall::*, *};
const WIDTH: usize = 10;
const HEIGHT: usize = 5;
@ -16,7 +13,7 @@ fn main() -> i32 {
print!("A");
}
println!(" [{}/{}]", i + 1, HEIGHT);
yield_();
sys_yield();
}
println!("Test write_a OK!");
0

@ -1,10 +1,7 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::yield_;
use user_lib::{syscall::*, *};
const WIDTH: usize = 10;
const HEIGHT: usize = 2;
@ -16,7 +13,7 @@ fn main() -> i32 {
print!("B");
}
println!(" [{}/{}]", i + 1, HEIGHT);
yield_();
sys_yield();
}
println!("Test write_b OK!");
0

@ -1,10 +1,7 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::yield_;
use user_lib::{syscall::*, *};
const WIDTH: usize = 10;
const HEIGHT: usize = 3;
@ -16,7 +13,7 @@ fn main() -> i32 {
print!("C");
}
println!(" [{}/{}]", i + 1, HEIGHT);
yield_();
sys_yield();
}
println!("Test write_c OK!");
0

@ -2,6 +2,7 @@ use core::arch::asm;
const SYSCALL_WRITE: usize = 64;
const SYSCALL_EXIT: usize = 93;
const SYSCALL_YIELD: usize = 124;
fn syscall(id: usize, args: [usize; 3]) -> isize {
@ -28,3 +29,7 @@ pub fn sys_exit(exit_code: i32) -> isize {
syscall(SYSCALL_EXIT, [exit_code as usize, 0, 0])
}
pub fn sys_yield() {
syscall(SYSCALL_YIELD, [0, 0, 0]);
}

Loading…
Cancel
Save