add process and task managers
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-05-14 17:39:55 +01:00
parent 6694bd2dd1
commit be684ab0f9
32 changed files with 816 additions and 93 deletions
@@ -153,7 +153,7 @@ impl HostRunner {
let mut firmware = Firmware::new(cap_config);
if let Some(root) = &fs_root {
let backend = HostDirBackend::new(root);
firmware.os.mount_fs(Box::new(backend));
firmware.os.vm_runtime.mount_fs(Box::new(backend));
}
Self {
@@ -204,7 +204,7 @@ impl HostRunner {
}
fn machine_running(&self) -> bool {
!self.firmware.os.paused && !self.debugger.waiting_for_start
!self.firmware.os.vm_runtime.paused && !self.debugger.waiting_for_start
}
}
@@ -320,23 +320,26 @@ impl ApplicationHandler for HostRunner {
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
let was_debugger_connected = self.debugger.stream.is_some();
let was_waiting_for_start = self.debugger.waiting_for_start;
let was_paused = self.firmware.os.paused;
let was_paused = self.firmware.os.vm_runtime.paused;
// 1. Process pending debug commands from the network.
self.debugger.check_commands(&mut self.firmware, &mut self.hardware);
// Sync inspection mode state. This is host-owned overlay/debugger control,
// not a guest-visible debug ABI switch.
self.firmware.os.inspection_active = self.overlay_enabled || self.debugger.stream.is_some();
self.firmware.os.vm_runtime.inspection_active =
self.overlay_enabled || self.debugger.stream.is_some();
// 2. Maintain filesystem connection if it was lost (e.g., directory removed).
if let Some(root) = &self.fs_root {
use prometeu_system::fs::FsState;
if matches!(self.firmware.os.fs_state, FsState::Unmounted | FsState::Error(_))
&& std::path::Path::new(root).exists()
if matches!(
self.firmware.os.vm_runtime.fs_state,
FsState::Unmounted | FsState::Error(_)
) && std::path::Path::new(root).exists()
{
let backend = HostDirBackend::new(root);
self.firmware.os.mount_fs(Box::new(backend));
self.firmware.os.vm_runtime.mount_fs(Box::new(backend));
}
}
@@ -361,13 +364,13 @@ impl ApplicationHandler for HostRunner {
// Unless the debugger is waiting for a 'start' command, advance the system.
if !self.debugger.waiting_for_start {
self.firmware.tick(&self.input.signals, &mut self.hardware);
self.stats.record_host_cpu_time(self.firmware.os.last_frame_cpu_time_us);
self.stats.record_host_cpu_time(self.firmware.os.vm_runtime.last_frame_cpu_time_us);
}
// Sync pause state with audio.
// We do this AFTER firmware.tick to avoid MasterPause/Resume commands
// being cleared by the OS if a new logical frame starts in this tick.
let is_paused = self.firmware.os.paused || self.debugger.waiting_for_start;
let is_paused = self.firmware.os.vm_runtime.paused || self.debugger.waiting_for_start;
if is_paused != self.last_paused_state {
self.last_paused_state = is_paused;
let cmd =
@@ -382,11 +385,11 @@ impl ApplicationHandler for HostRunner {
self.stats.record_frame();
}
self.presentation.note_published_frame(self.firmware.os.logical_frame_index);
self.presentation.note_published_frame(self.firmware.os.vm_runtime.logical_frame_index);
if was_debugger_connected != self.debugger.stream.is_some()
|| was_waiting_for_start != self.debugger.waiting_for_start
|| was_paused != self.firmware.os.paused
|| was_paused != self.firmware.os.vm_runtime.paused
{
self.invalidate_host_surface();
}
@@ -400,9 +403,9 @@ impl ApplicationHandler for HostRunner {
// Synchronize system logs to the host console.
let last_seq = self.log_sink.last_seq().unwrap_or(u64::MAX);
let new_events = if last_seq == u64::MAX {
self.firmware.os.log_service.get_recent(4096)
self.firmware.os.vm_runtime.log_service.get_recent(4096)
} else {
self.firmware.os.log_service.get_after(last_seq)
self.firmware.os.vm_runtime.log_service.get_after(last_seq)
};
self.log_sink.process_events(new_events);
@@ -812,7 +815,7 @@ mod tests {
stream.write_all(b"{\"type\":\"pause\"}\n").expect("Should write pause");
std::thread::sleep(std::time::Duration::from_millis(50));
runner.debugger.check_commands(&mut runner.firmware, &mut runner.hardware);
assert!(runner.firmware.os.paused, "VM should be paused");
assert!(runner.firmware.os.vm_runtime.paused, "VM should be paused");
}
// 2. Disconnect (stream goes out of scope)
@@ -820,7 +823,7 @@ mod tests {
runner.debugger.check_commands(&mut runner.firmware, &mut runner.hardware);
// 3. Check if unpaused
assert!(!runner.firmware.os.paused, "VM should have unpaused after disconnect");
assert!(!runner.firmware.os.vm_runtime.paused, "VM should have unpaused after disconnect");
assert!(!runner.debugger.waiting_for_start, "VM should have left waiting_for_start state");
}
}