ke: add continuations

This commit is contained in:
Loïc Grégoire
2026-08-29 20:03:22 -04:00
parent d06351f31c
commit 8226a205a0
20 changed files with 735 additions and 194 deletions
+6 -4
View File
@@ -72,7 +72,7 @@ fn reader(param: ?*anyopaque) void {
_ = reads.fetchAdd(done, .monotonic);
if (iter % 512 == 0) ke.sched.yield();
if (iter % 512 == 0) ke.sched.yield(null);
}
}
@@ -109,7 +109,7 @@ fn writer(param: ?*anyopaque) void {
_ = writes.fetchAdd(1, .monotonic);
if (iter % 256 == 0) ke.sched.yield();
if (iter % 256 == 0) ke.sched.yield(null);
}
}
@@ -130,12 +130,14 @@ fn poller(_: ?*anyopaque) void {
_ = polls.fetchAdd(1, .monotonic);
ke.sched.yield();
ke.sched.yield(null);
}
}
fn spawn(entry: *const fn (?*anyopaque) void, id: usize) void {
const t = ps.thread.create_kernel(.Default, entry, @ptrFromInt(id + 1)) catch @panic("oom");
const t = ps.thread.create_kernel(.Default, .{.func = entry, .arg = @ptrFromInt(id + 1)}, true)
catch
@panic("oom");
ke.sched.enqueue(&t.kern);
}