fix: disable test harness for no_std binaries, fix shutdown to best-effort notify-and-halt, use CapSlot newtypes
This commit is contained in:
@@ -3,6 +3,11 @@ name = "adapter-riscv"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "adapter-riscv"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
types = { workspace = true }
|
||||
domain = { workspace = true }
|
||||
|
||||
@@ -3,6 +3,11 @@ name = "hello"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "hello"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
userspace = { workspace = true }
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ name = "snake"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "snake"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
types = { workspace = true }
|
||||
userspace = { workspace = true }
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
const SHUTDOWN_TIMEOUT_TICKS: usize = 50_000_000;
|
||||
use types::bounded::CapSlot;
|
||||
|
||||
pub fn shutdown(server_endpoints: &[usize], endpoint_count: usize) -> ! {
|
||||
const SHUTDOWN_TIMEOUT_TICKS: usize = 50_000_000;
|
||||
const SHUTDOWN_SIGNAL: usize = 0xFFFF_FFFF;
|
||||
|
||||
/// Best-effort shutdown: notify all servers, wait briefly for them to flush, then halt.
|
||||
///
|
||||
/// Servers that receive the shutdown signal should flush state to storage and exit.
|
||||
/// We can't block on individual acks because a crashed server would deadlock us.
|
||||
/// Instead, we yield repeatedly until the timeout expires, giving servers time to finish.
|
||||
pub fn shutdown(server_endpoints: &[CapSlot], endpoint_count: usize) -> ! {
|
||||
for i in 0..endpoint_count {
|
||||
let ep = server_endpoints[i];
|
||||
if ep != 0 {
|
||||
userspace::syscall::send(ep, 0xFFFF_FFFF, 0, 0, 0);
|
||||
}
|
||||
let ep = server_endpoints[i].value() as usize;
|
||||
userspace::syscall::send(ep, SHUTDOWN_SIGNAL, 0, 0, 0);
|
||||
}
|
||||
|
||||
let start = userspace::syscall::get_time();
|
||||
let deadline = start + SHUTDOWN_TIMEOUT_TICKS;
|
||||
|
||||
let mut acks = 0usize;
|
||||
while acks < endpoint_count {
|
||||
let now = userspace::syscall::get_time();
|
||||
if now >= deadline {
|
||||
break;
|
||||
}
|
||||
acks += 1;
|
||||
while userspace::syscall::get_time() < deadline {
|
||||
userspace::syscall::yield_now();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user