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"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "adapter-riscv"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
types = { workspace = true }
|
types = { workspace = true }
|
||||||
domain = { workspace = true }
|
domain = { workspace = true }
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ name = "hello"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "hello"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
userspace = { workspace = true }
|
userspace = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ name = "snake"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "snake"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
types = { workspace = true }
|
types = { workspace = true }
|
||||||
userspace = { 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 {
|
for i in 0..endpoint_count {
|
||||||
let ep = server_endpoints[i];
|
let ep = server_endpoints[i].value() as usize;
|
||||||
if ep != 0 {
|
userspace::syscall::send(ep, SHUTDOWN_SIGNAL, 0, 0, 0);
|
||||||
userspace::syscall::send(ep, 0xFFFF_FFFF, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let start = userspace::syscall::get_time();
|
let start = userspace::syscall::get_time();
|
||||||
let deadline = start + SHUTDOWN_TIMEOUT_TICKS;
|
let deadline = start + SHUTDOWN_TIMEOUT_TICKS;
|
||||||
|
|
||||||
let mut acks = 0usize;
|
while userspace::syscall::get_time() < deadline {
|
||||||
while acks < endpoint_count {
|
|
||||||
let now = userspace::syscall::get_time();
|
|
||||||
if now >= deadline {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
acks += 1;
|
|
||||||
userspace::syscall::yield_now();
|
userspace::syscall::yield_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user