ps+ke: add thread reaping

This commit is contained in:
Loïc Grégoire
2026-06-29 17:12:46 -04:00
parent bf08a9fef2
commit a9c933114d
10 changed files with 140 additions and 46 deletions
+4 -3
View File
@@ -150,8 +150,7 @@ fn particle(param: ?*anyopaque) void {
data.vel_y += @divTrunc(int_to_fp(10) * delay, 1000);
}
// Now block.
ke.sched.block();
ps.thread.exit();
}
fn spawn_particle(arg: ?*anyopaque) void {
@@ -214,7 +213,7 @@ fn explodeable(_: ?*anyopaque) void {
spawn_particle(param);
}
ke.sched.block();
ps.thread.exit();
}
pub fn start(param: ?*anyopaque) void {
@@ -239,6 +238,8 @@ pub fn start(param: ?*anyopaque) void {
spawn_explodeable();
}
std.log.info("async: {}, sync: {}, usable memory: {} KiB", .{ mm.private.tlb.async_shootdowns.load(.monotonic), mm.private.tlb.sync_shootdowns.load(.monotonic), mm.private.phys.usable_memory.load(.monotonic) / 1024 });
perform_delay(2000);
}
}
+3 -3
View File
@@ -21,10 +21,10 @@ pub fn init(boot_info: *pl.BootInfo) void {
exp.console.init();
if (boot_info.framebuffer != null) {
fbconsole.init(boot_info);
// fbconsole.init(boot_info);
// const t = ps.thread.create_kernel(ke.Thread.Priority.default, ex.fireworks.start, boot_info) catch @panic("oom");
// ke.sched.enqueue(&t.kern);
const t = ps.thread.create_kernel(ke.Thread.Priority.default, ex.fireworks.start, boot_info) catch @panic("oom");
ke.sched.enqueue(&t.kern);
}
while (true) {
+2 -2
View File
@@ -38,8 +38,8 @@ pub const WorkItem = struct {
}
};
pub fn init(priority: Priority, func: *const fn (arg: ?*anyopaque) void, arg: ?*anyopaque) WorkItem {
return .{
pub fn init(self: *WorkItem, priority: Priority, func: *const fn (arg: ?*anyopaque) void, arg: ?*anyopaque) void {
self.* = .{
.func = func,
.arg = arg,
.link = undefined,