ke/smr: expose simpler APIs

This commit is contained in:
Loïc Grégoire
2026-07-26 20:41:01 -04:00
parent 1dedb5dba1
commit 9c48a5207c
3 changed files with 14 additions and 2 deletions
+2
View File
@@ -92,6 +92,8 @@ pub const smr = struct {
pub const exit = p.smr.exit;
pub const enter = p.smr.enter;
pub const poll = p.smr.poll;
pub const wait = p.smr.wait;
pub const synchronize = p.smr.synchronize;
pub const seq_invalid = p.smr.seq_invalid;
+10
View File
@@ -321,6 +321,16 @@ pub fn exit(dom: *Domain, ipl: ke.Ipl) void {
ke.ipl.lower(ipl);
}
/// Wait for a given goal to happen.
pub fn wait(dom: *Domain, goal: Sequence) void {
poll(dom, goal, true);
}
/// Wait until all readers have left their read sections.
pub fn synchronize(dom: *Domain) void {
wait(dom, advance(dom));
}
// Called by the scheduler when a thread in an SMR section got preempted.
pub fn mark_thread_stalled(td: *ke.Thread) void {
var it = td.smr_sections.iterator();
+2 -2
View File
@@ -801,7 +801,7 @@ pub const Zone = struct {
if (self.smr) |smr| {
// Direct frees must synchronize, the object is instantly reusable.
_ = ke.smr.poll(smr, ke.smr.advance(smr), true);
_ = ke.smr.synchronize(smr);
}
self.lock.acquire();
@@ -1080,7 +1080,7 @@ pub const Zone = struct {
ke.smr.deferred_advance_commit(smr, magazine.seq);
// Wait until we can destroy the magazine.
_ = ke.smr.poll(smr, magazine.seq, true);
_ = ke.smr.wait(smr, magazine.seq);
}
}