User base from 0x0->0x10000; user image size limit from 128MB->16MB; trigger race condition on k210
This commit is contained in:
parent
a341b338c8
commit
ff5055386b
5 changed files with 18 additions and 14 deletions
|
@ -5,20 +5,21 @@
|
|||
extern crate user_lib;
|
||||
extern crate alloc;
|
||||
|
||||
use user_lib::{exit, thread_create, waittid};
|
||||
use user_lib::{exit, thread_create, waittid, get_time};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
static mut A: usize = 0;
|
||||
const PER_THREAD: usize = 10000000;
|
||||
const THREAD_COUNT: usize = 50;
|
||||
const PER_THREAD: usize = 2000000;
|
||||
const THREAD_COUNT: usize = 8;
|
||||
|
||||
unsafe fn f() -> ! {
|
||||
let start = get_time();
|
||||
for _ in 0..PER_THREAD {
|
||||
let a = &mut A as *mut usize;
|
||||
let cur = a.read_volatile();
|
||||
a.write_volatile(cur + 1);
|
||||
}
|
||||
exit(0)
|
||||
exit((get_time() - start) as i32)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -27,10 +28,13 @@ pub fn main() -> i32 {
|
|||
for _ in 0..THREAD_COUNT {
|
||||
v.push(thread_create(f as usize) as usize);
|
||||
}
|
||||
let mut time_cost = Vec::new();
|
||||
for tid in v.iter() {
|
||||
waittid(*tid);
|
||||
time_cost.push(waittid(*tid));
|
||||
}
|
||||
for (i, cost) in time_cost.iter().enumerate() {
|
||||
println!("cost of thread#{} is {}ms", i, cost);
|
||||
}
|
||||
assert_eq!(unsafe { A }, PER_THREAD * THREAD_COUNT);
|
||||
println!("total = {}", unsafe { A });
|
||||
0
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
|
||||
BASE_ADDRESS = 0x0;
|
||||
BASE_ADDRESS = 0x10000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
@ -29,4 +29,4 @@ SECTIONS
|
|||
*(.eh_frame)
|
||||
*(.debug*)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue