Add sys_yield tests and compile them to different location.

This commit is contained in:
Yifan Wu 2020-11-28 16:22:29 +08:00
parent 1414d05325
commit 4e8059e222
12 changed files with 99 additions and 57 deletions

View file

@ -1,11 +0,0 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
#[no_mangle]
fn main() -> i32 {
println!("Hello, world!");
0
}

18
user/src/bin/00write_a.rs Normal file
View file

@ -0,0 +1,18 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::sys_yield;
#[no_mangle]
fn main() -> i32 {
for _ in 0..3 {
for _ in 0..10 { print!("A"); }
println!("");
sys_yield();
}
println!("Test write_a OK!");
0
}

View file

@ -1,14 +0,0 @@
#![no_std]
#![no_main]
#![feature(llvm_asm)]
#[macro_use]
extern crate user_lib;
#[no_mangle]
fn main() -> i32 {
println!("Into Test store_fault, we will insert an invalid store operation...");
println!("Kernel should kill this application!");
unsafe { (0x0 as *mut u8).write_volatile(0); }
0
}

18
user/src/bin/01write_b.rs Normal file
View file

@ -0,0 +1,18 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::sys_yield;
#[no_mangle]
fn main() -> i32 {
for _ in 0..3 {
for _ in 0..10 { print!("B"); }
println!("");
sys_yield();
}
println!("Test write_b OK!");
0
}

View file

@ -1,27 +0,0 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
const SIZE: usize = 10;
const P: u32 = 3;
const STEP: usize = 100000;
const MOD: u32 = 10007;
#[no_mangle]
fn main() -> i32 {
let mut pow = [0u32; SIZE];
let mut index: usize = 0;
pow[index] = 1;
for i in 1..=STEP {
let last = pow[index];
index = (index + 1) % SIZE;
pow[index] = last * P % MOD;
if i % 10000 == 0 {
println!("{}^{}={}", P, i, pow[index]);
}
}
println!("Test power OK!");
0
}

18
user/src/bin/02write_c.rs Normal file
View file

@ -0,0 +1,18 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::sys_yield;
#[no_mangle]
fn main() -> i32 {
for _ in 0..3 {
for _ in 0..10 { print!("C"); }
println!("");
sys_yield();
}
println!("Test write_c OK!");
0
}