Skip to content

Cells, epochs, and lifecycle

A handle, a channel or a pending call is only meaningful for the cell lifetime that issued it. The kernel names that lifetime with two values: a cell id, which names an owner domain, and a cell epoch, which names one concrete lifetime of that domain. Everything a cell issues is bound to both, and the nucleus alone moves a cell from one lifecycle state to the next. This page covers what the id and epoch bind, the cell's lifecycle states, and the receipt each transition waits for.

Lifecycle states

stateDiagram-v2
  [*] --> requested
  requested --> starting: StartCell issued
  starting --> registered: CellMonitorRegistered
  registered --> ready: ProviderReady
  ready --> quiescing: drain
  quiescing --> drained
  ready --> terminating: TerminateGuest issued
  quiescing --> terminating
  drained --> terminating
  failed --> terminating
  terminating --> terminated: ProcessExited
  terminated --> [*]
  requested --> failed
  starting --> failed
  registered --> failed
  ready --> failed
  quiescing --> failed

The states are a closed set. terminated is the only terminal state, every other state can reach it, and a failure in any earlier state passes through failed and terminating on its way there. A transition outside this graph is refused with a typed lifecycle refusal.

Receipts move a cell

The nucleus is the lifecycle authority. The nucleus host and the cell monitor report facts, and a cell advances only when the nucleus admits the receipt that transition requires:

Receipt Proves Permits
ProcessStarted The contained monitor process exists The monitor-registration request; the cell stays starting
CellMonitorRegistered An authenticated control-channel peer for this exact cell id and epoch starting to registered
ProviderReady The registered monitor completed protocol negotiation and provider preparation for the same cell and epoch registered to ready
ProcessExited The operating system reported the process gone terminating to terminated

Each receipt satisfies one transition only. A ProcessStarted receipt leaves a cell starting, so a cell whose monitor never registers stays out of ready and receives no dispatch.

What the epoch binds

Handles, monitor registration, provider readiness, effects and receipts all carry the cell id and the cell epoch. Admission compares the presented epoch with the current one for equality:

  • an epoch behind the current one names a lifetime that ended, and the request is refused as stale;
  • an epoch ahead of the current one names a lifetime the nucleus never issued, and the request is refused.

Replacing a monitor or a provider process ends the epoch. A restart creates a new epoch with empty tables, and handles, resources and pending calls from the earlier epoch stay invalid. See The kernel epoch contract.

What crosses a cell boundary

Live objects and owner-local state stay in the cell that created them for the whole epoch. Three things cross a cell boundary: typed values, declared buffer attachments, and execution requests that enter through the kernel. See The core invariant.