mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add a pair of swap test servers
these do nothing but allocate a bunch of memory and revisit the allocated memory, to exercise swapping.
This commit is contained in:
parent
aad14c2cca
commit
415fa27758
4 changed files with 114 additions and 0 deletions
13
services/swaptest1/Cargo.toml
Normal file
13
services/swaptest1/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "swaptest1"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
xous = { version = "0.9.68", features = ["raw-trng"] }
|
||||
xous-ipc = "0.10.8"
|
||||
xous-names = { package = "xous-api-names", version = "0.9.69" }
|
||||
ticktimer = { package = "xous-api-ticktimer", version = "0.9.67" }
|
||||
log-server = { package = "xous-api-log", version = "0.1.67" }
|
||||
log = "0.4.14"
|
||||
arbitrary-int = "1.2"
|
||||
44
services/swaptest1/src/main.rs
Normal file
44
services/swaptest1/src/main.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
fn main() {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
const HEAP_LARGER_LIMIT: usize = 4096 * 1024;
|
||||
let new_limit = HEAP_LARGER_LIMIT;
|
||||
let result =
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(xous::Limits::HeapMaximum as usize, 0, new_limit));
|
||||
|
||||
if let Ok(xous::Result::Scalar2(1, current_limit)) = result {
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(
|
||||
xous::Limits::HeapMaximum as usize,
|
||||
current_limit,
|
||||
new_limit,
|
||||
))
|
||||
.unwrap();
|
||||
log::info!("Heap limit increased to: {}", new_limit);
|
||||
} else {
|
||||
panic!("Unsupported syscall!");
|
||||
}
|
||||
|
||||
let mut test_vec = Vec::new();
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let sid = xns.register_name("swaptest1", None).expect("can't register server");
|
||||
let mut msg_opt = None;
|
||||
|
||||
const ALLOC_SIZE: usize = 1024 * 256;
|
||||
loop {
|
||||
xous::reply_and_receive_next(sid, &mut msg_opt).unwrap();
|
||||
if let Some(scalar) = msg_opt.as_ref().unwrap().body.scalar_message() {
|
||||
log::info!("kicking off swaptest1 {}", scalar.arg1);
|
||||
for i in 0..ALLOC_SIZE {
|
||||
test_vec.push(i + scalar.arg1);
|
||||
}
|
||||
let mut sum = 0;
|
||||
for i in (0..ALLOC_SIZE).rev() {
|
||||
sum += test_vec[i];
|
||||
}
|
||||
log::info!("swaptest1: {}", sum);
|
||||
test_vec.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
services/swaptest2/Cargo.toml
Normal file
13
services/swaptest2/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "swaptest2"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
xous = { version = "0.9.68", features = ["raw-trng"] }
|
||||
xous-ipc = "0.10.8"
|
||||
xous-names = { package = "xous-api-names", version = "0.9.69" }
|
||||
ticktimer = { package = "xous-api-ticktimer", version = "0.9.67" }
|
||||
log-server = { package = "xous-api-log", version = "0.1.67" }
|
||||
log = "0.4.14"
|
||||
arbitrary-int = "1.2"
|
||||
44
services/swaptest2/src/main.rs
Normal file
44
services/swaptest2/src/main.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
fn main() {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
const HEAP_LARGER_LIMIT: usize = 4096 * 1024;
|
||||
let new_limit = HEAP_LARGER_LIMIT;
|
||||
let result =
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(xous::Limits::HeapMaximum as usize, 0, new_limit));
|
||||
|
||||
if let Ok(xous::Result::Scalar2(1, current_limit)) = result {
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(
|
||||
xous::Limits::HeapMaximum as usize,
|
||||
current_limit,
|
||||
new_limit,
|
||||
))
|
||||
.unwrap();
|
||||
log::info!("Heap limit increased to: {}", new_limit);
|
||||
} else {
|
||||
panic!("Unsupported syscall!");
|
||||
}
|
||||
|
||||
let mut test_vec = Vec::new();
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let sid = xns.register_name("swaptest2", None).expect("can't register server");
|
||||
let mut msg_opt = None;
|
||||
|
||||
const ALLOC_SIZE: usize = 1024 * 256;
|
||||
loop {
|
||||
xous::reply_and_receive_next(sid, &mut msg_opt).unwrap();
|
||||
if let Some(scalar) = msg_opt.as_ref().unwrap().body.scalar_message() {
|
||||
log::info!("kicking off swaptest2 {}", scalar.arg1);
|
||||
for i in 0..ALLOC_SIZE {
|
||||
test_vec.push(i + scalar.arg1);
|
||||
}
|
||||
let mut sum = 0;
|
||||
for i in (0..ALLOC_SIZE).rev() {
|
||||
sum += test_vec[i];
|
||||
}
|
||||
log::info!("swaptest2: {}", sum);
|
||||
test_vec.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue