decisions AMENDED

147. A timer a userspace service cannot hold

(one amendment block below, from milestone 106 (a wait that ends on either the interrupt or the deadline)'s own PR.)

calef, 2026-09-05: option 1, the new object. Option 2 was ruled out first ("§19 exists to make this expensive", and a scope note recording something that cannot be done is not the thing a scope note is for). Between 1 and 3 his reason was one sentence: "A new object seems like the winner. A deadline argument seems like a work around to reduce effort."

That is §92 (a caretaker is supervised by the client it serves)'s test applied, and it is worth recording as such because §92 exists for exactly this shape: "the failure mode is not laziness, it is a recommendation that sounds like design." Milestone 51 (wall-clock time, the date command, and an NTP service) called the deadline argument strongest on "three problems, one addition", which counts effort. Asked §92's question, would I still choose this if both options were the same amount of work, it loses on the merits:

Two of option 3's three shapes never reached the comparison, and this section says so rather than leaving them as live alternatives. SYS_SLEEP is ambient, which §10 refuses by design, and answers one of four consumers. A timer object with a blocking WAIT has one wake source, so it does not meet milestone 106's own title, which is a wait ending on either the interrupt or the deadline. Option 1 is that shape with the blocking removed, which is what makes it work.

The cost accepted. This is two builds rather than one. Milestone 151 (notification objects) must land first, and is NOT-STARTED: without the TCB binding this buys a thread a timer and no way to wait on a timer and a message at once. Option 1 is 151 plus one object and was priced that way.

(Was PROPOSED from 2026-09-05, written by milestone 263 (can a userspace process hold a timer, on all three architectures)'s lane, which named no winner deliberately. It was raised because that spike's answer invalidated the premise of a decision calef had made the same day. AGENTS.md's rule is that an irreversible fork arrives with options rather than a recommendation. He ruled it the same day it was written.)

What is being decided

Milestone 106 asks for a wait that ends on either a message or a deadline. calef decided on 2026-09-05 to serve it from a userspace timer service signaling a notification, rather than from a new kernel blocking primitive. He minted milestone 263 to price the prerequisite: whether such a service can hold a timer at all.

It cannot, on riscv64, on any machine. So the decision needs re-making, and this is the fork.

Why the premise failed

The full working, with the specification citations, is notes/timer-capability/specifications.md, and the corrected per-architecture table is in design/roadmap/0263-can-a-timer-be-a-capability.md. The short form:

§19 (architectural parity is a tenet) is what makes this a decision rather than a port task. A capability that ships on two of three architectures is a scope note at best, and this gap is permanent: no amount of work closes it, because the RISC-V privileged architecture has nothing to open.

The options

Option 1: the fourth shape, Timer::ARM(deadline, notification)

The kernel owns the comparator on every architecture, which is where two of three put it anyway, and signals a notification at the deadline on the holder's behalf. A thread blocks in RECV with the notification bound to its TCB (§101) and wakes on either.

Measured (milestone 263's scaffold, built, gated green with script/test, and deleted):

what figure
the Object variant free; the enum is already 24 bytes wide because of PageFrame
ipc_fastpath unchanged on all three ISAs
system_call_entry (flat) aarch64 +12 B, riscv64 +158 B, x86_64 +96 B
kernel symbol bytes +738 B / +2,266 B / +1,386 B, all under 0.25%
per-tick bookkeeping already priced in notes/timed-wait.md: one comparison per idle tick

What it costs that is not bytes. A system-call-surface addition, permanent, that every future program is written against. And a dependency on milestone 151, which is unbuilt. Without §101 (notification objects)'s TCB binding this buys a thread a timer it can block on and no way to block on a timer and a message at once, which is milestone 106's actual complaint. Option 1 is 151 plus one object, and pricing it any other way understates it.

Option 2: a userspace service on aarch64 and x86_64, with a riscv64 scope note

Keeps the 2026-09-05 decision on two architectures and records the third as a gap.

What it costs. §19 exists to make this expensive, and the usual mitigating argument does not apply: a scope note normally records a port that has not been done, and this one would record something that cannot be done. It is also worse than two-of-three suggests, because the aarch64 half rests on the CNTP_* comparator, which traps under a hypervisor and is one per PE. riscv64 programs would need a different timed wait from the other two, which is the "a feature works on one ISA and silently not another" shape rule 5 names as the bug. It also needs aarch64's per-thread CNTKCTL_EL1 grant built (the machinery exists; the policy does not) and the hypervisor caveat accepted, and it needs xenon's HPET confirmed before anything on x86_64 is real.

Option 3: reopen milestone 51's three shapes

SYS_SLEEP, a timer object, or a deadline argument on RECV/CALL. notes/timed-wait.md prices all three and names no winner, deliberately. This spike does not price them and does not need to: they were never blocked on the question 263 answered.

What it costs. The fork calef declined to decide on 2026-09-05 comes back, which is the outcome his decision was avoiding. It is worth saying that the reason he could avoid it was the userspace service, and that reason is gone.

What is blocked until this is answered

What this file does not do

It did not recommend, and that was on purpose. AGENTS.md: "Recommend on reversible forks; give options only on irreversible ones", and a system-call-surface addition is the named example on the irreversible side. Milestone 263's lane priced the options and stopped there; calef ruled from the prices. Kept in the past tense rather than deleted, because how a decision was reached is part of the record. A reader who finds a file that names a winner should be able to see that the winner was not this file's to name.

It also does not amend §139 (who may read the cycle counter, and by what authority), which says "There is no precedent in this tree for a per-thread system-register bit maintained across a context switch." Milestones 229 and 237 built one, so that sentence is stale inside its own decision. The correction is recorded in notes/timer-capability/specifications.md and in 263's block; amending a decision section is not a lane's to do.

Amendment (milestone 106): the system call numbers, bits, and no slack argument

This section's option 1 named the shape, Timer::ARM(deadline, notification), and left the numbers and one detail to the building lane. Milestone 106's PR (#1378) asked for both, and calef ruled on the surface it built rather than the shape alone.

object_type::TIMER = 5, the module's name spelled out by the ruling of 2026-11-11 (UTC). A Timer is retyped from untyped by MemoryRegion::RETYPE_OBJECT (method 2, its name spelled out by the same ruling), the same route as every other kernel object §147 already assumed. calef, 2026-09-27T01:59:29Z (UTC), on PR #1378: "Confirmed", against the lane's proposal of objtype::TIMER = 5 and Timer::ARM = 0 / Timer::CANCEL = 1.

Timer::ARM(deadline, notification_slot, bits) = 0, a third argument beyond this section's text. invoke(cap, ARM, deadline, notification_slot, bits) arms the timer: when the counter reaches deadline, the kernel ORs bits into the notification named by notification_slot, exactly as notification::SIGNAL(bits) would. Arming replaces any pending deadline, which then never fires; a deadline already reached signals at once and leaves nothing armed. bits = 0 is accepted and delivers nothing when the deadline passes, the same reading SIGNAL(0) already has (it wakes nobody, because it has nothing to deliver). A timer armed with bits = 0 still consumes and replaces the pending deadline; it just signals nothing when it fires. Needs WRITE on the timer and on the notification (the same right SIGNAL itself needs, because arming is signaling later); WrongObject if the slot named is not a notification. A notification destroyed while the timer is armed makes the expiry a no-op, not an error: there is nobody left to tell.

Deadlines are absolute counter ticks, the same counter a program already reads without a system call (CNTVCT_EL0, rdtime, rdtsc); nothing converts between clocks. Resolution is the scheduler tick, 100 Hz / 10 ms: a deadline fires at the first tick at or after it, never before.

Timer::CANCEL = 1. invoke(cap, CANCEL, _, _, _) disarms the timer: 1 if a deadline was pending and now never fires, 0 if nothing was armed (never armed, already fired, or already cancelled). The return distinguishes the two so a caller can tell whether its own signal already went out. A cancel does not reach into the notification's word: bits a timer already signaled stay there, because a notification never loses a bit.

No slack argument. calef, 2026-09-27T02:00:47Z (UTC), on PR #1378, after reading the prior art this section's option 1 did not need to (Zircon's zx_timer_set, which carries one; Mach's mk_timer; seL4's badge bits; Linux timerfd; kqueue): "Keep it confirmed. We will build a slack if we need it." ARM takes exactly three arguments beyond the object and method. A slack would be a later, additive system call change, only if a tickless kernel ever needs one; this kernel's timer is tick-resolution already, so there is nothing for a slack to buy today.

Both rulings are calef's own comments on #1378, relayed there under his account by the maintainer lane that opened the PR; the exact wording and both timestamps are quoted as posted. The full surface, with its rationale in prose, is crates/moho_abi/src/lib.rs's objtype::TIMER and timer module doc comments on that branch.