Process Definitions
ProcessDecl ::= Bind? 'proc' UIdent '(' (Param (',' Param)*)? ')' '{' ProcessBody '}'
Bind ::= '@bind' '(' ident '.' ident (',' ident '.' ident)* ')'
Param ::= ident ':' Type
ProcessBody ::= BodyItem (';' BodyItem)* ';'?
BodyItem ::= VarDecl | ProcessExpr
VarDecl ::= ident ':' Type ';'
ProcessExpr ::= 'Skip'
| 'Div'
| Event '->' ProcessExpr
| '[' Guard ']' ProcessExpr
| ProcessExpr ('[]' ProcessExpr)* ('default' ProcessExpr)?
| ProcessRef
| '(' ProcessExpr (';' ProcessExpr)* ')'
ProcessRef ::= UIdent '(' (ident (',' ident)*)? ')'
Guard ::= Expr -- boolean-shaped: comparison, &&/||/!, boolean
-- variable/call/field access; not arithmetic
A process definition is the orchestration layer of a Fiducia protection
domain — a CSP-style algebraic expression composed from
events, guards, choices, and sequential composition.
Each proc declaration introduces one named process; all proc
declarations in the same .fi file are mutually visible and may reference
each other by name.
proc definitions and evt declarations may appear in any order in the
file.
Following the CoreFi paper §4.2, a process expression is one of:
| Form | Notation | Meaning |
|---|---|---|
| Successful exit | Skip | Terminates normally. |
| Divergence | Div | Divergence (a self-loop, Ω). |
| Event prefix | e -> P | Performs event e, then P. |
| Guard | [b] P | Performs P only if b holds. |
| External choice | P [] Q | Either branch — environment chooses. |
| Default arm | (P [] Q) default R | R runs when no branch is enabled. |
| Sequential | P ; Q | P to completion, then Q. |
| Reference | Name(args) | Calls another process declaration. |
Naming convention
Process names start with an uppercase letter (UpperCamelCase); the parser
requires it. With the parentheses, this sets process references apart from
computation event references:
Reply(pkt)— sub-process call (UpperCamelCase, parentheses required).send_frame.pkt— computation-event reference (snake_caseby convention, dot carrier syntax).
An uppercase name followed by ( is a process reference; any other
identifier before -> is an event.
The boot process is the one bound with @bind(microkit.init); Init is a
conventional name but carries no special meaning (see
Boot Initialisation).
Annotations (@bind)
A process may carry a single @bind(...) annotation mapping it to one or
more platform entry points, without hardcoding kernel terminology into
process names. Group the targets — one platform.entry pair per platform —
on one line:
@bind(microkit.notified, cheri.interrupt_handler)
proc Notified() { o2d?pkt -> d2i!pkt -> Notified(); }
- A process with no
@bindis internal — not directly callable by the kernel. @bindis authoritative for entry-point selection. The C backend and the UPPAAL lowering pick kernel entry points by binding, not by process name: themicrokit.init-bound process becomesinit()(the boot body), themicrokit.notified-bound process becomes thenotified()event loop, and amicrokit.protected-bound process becomesprotected(), which answers aSyncchannel’s call.- The process bound to
microkit.notified, if it receives at all, should be receive-headed (a warning otherwise): every path at its head, through[], the left of;and a helper’s body, begins with a receive (c?x) or an IRQ await (irq?N), with no guard and nodefaultat the top, and no receive sits anywhere else. The kernel invokes it for a message, which the head consumes; a handler that could run without one would never return to the kernel. See Well-Formedness. - Both a
@bind(microkit.init)and a@bind(microkit.notified)process are mandatory for every PD with a program when targeting Microkit — Microkit invokes both on every PD, and the front end reports a PD that lacks one whatever the output (--check,--emit=xta,--emit=c, an image). See Boot Initialisation and Entry Points.microkit.protectedis optional, and bound only where aSyncchannel ends at the PD; its process is receive-headed on those channels and runs to completion (see Well-Formedness). Other platform entry points are optional. - Each entry point binds at most one process. Two processes both
@bind(microkit.notified)is an error — resolution rejects the second rather than silently keeping the first.
Operator precedence
From loosest to tightest:
| Precedence | Operator | Notation | Note |
|---|---|---|---|
| 1 (loosest) | Sequential | ; | Separates body items. |
| 2 | External choice | [] / default | Each branch must carry a discriminator. |
| 3 | Guard | [b] P | Guard binds the next expression only. |
| 4 (tightest) | Event prefix | -> | Right-associative (Hoare CSP, page 4). |
| atoms | Skip, Div, (...), Name(args) |
Concrete consequences:
e -> P() [] e2 -> Q() ≡ Choice([Prefix(e, P()), Prefix(e2, Q())])
e -> P() ; Q() ≡ (e -> P()) ; Q()
[b] e -> P() [] e2 -> Q() ≡ Choice([Guard(b, Prefix(e, P())), Prefix(e2, Q())])
P1() ; P2() [] P3() ≡ P1() ; (P2() [] P3())
[b] (e -> P() [] e2 -> Q()) ≡ Guard(b, Choice(...)) // outer-guard the choice
Parenthesisation cuts through: (...) re-enters at the top of the
precedence chain.
Choice and discriminators
Every branch of a [] choice must carry a discriminator — a
distinguishing prefix that the surrounding environment can pattern-match
on. The parser checks structurally and recurses into a branch’s first
sequential item and into nested choices; a ProcessRef branch is admitted
as it is, and the name is not followed.
Common discriminator shapes:
e -> P() // event prefix
[b] P() // guard
c?x -> ... // channel-event prefix
A branch that is bare Skip, Div or a variable declaration is a parse
error: it is always enabled, so it discriminates nothing. A branch that is
a sequence is judged by its first item.
The optional default arm is taken when no branch’s guard succeeds. It
needs no discriminator of its own. A receive beside a default is a
receive outside the head, and a warning (see
Well-Formedness).
Examples
// Two branches, no default.
proc Dispatch() {
[rx] receive -> Skip [] [!rx] cleanup -> Skip;
}
// Two branches with a fallback.
proc Reply(pkt: int) {
[pass] o2d!pkt -> Skip
[] [!pass] handle_ping -> Skip
default Skip;
}
Guards
Guard ::= Expr -- boolean-shaped: comparison, &&, ||, !, a boolean
-- variable, call or field access; not arithmetic
A guard gates the next process expression on a boolean
expression: [rounds < 3], [!ready],
[io.keep_playing(rounds) != 0]. A guard whose top node is arithmetic ([a + b]),
an integer literal or sizeof is rejected; arithmetic inside a comparison
([a + b == c]) is fine. The guard binds tighter than []:
[b] e -> P [] e2 -> Q ≡ ([b] (e -> P)) [] (e2 -> Q)
The guard applies only to the first branch.
Recursion
A process refers to a process that is already running (itself, or one that called it) only in tail position: as the last thing it does, so the reference is a jump back to that process’s head and the control graph stays finite. Such a reference followed by more work is rejected; a first call to a helper may be followed by more work:
proc Notified() { ball? -> Notified(); tally -> Skip; } // error: non-tail
proc Notified() { ball? -> tally -> Notified(); } // ok
This holds for the entry process too: Notified() at the end of
Notified loops back to its head within the invocation. Only reaching the
end (Skip) returns to the kernel, and the next notification invokes
notified again. A loop whose head receives waits there for the next
message; one that never receives never returns (Skip; Notified() on a
PD’s own CPU budget).
Inside a non-final operand of ;, no enclosing process may be referenced:
its continuation would need a return stack. See
Well-Formedness.
Sequential composition
Inside a {} body, ; separates items. The last item may carry a
trailing ; before }:
proc Notified() {
irq?159 -> Handle_eth();
irq!159 -> Notified();
}
Sub-process calls
ProcessRef ::= UIdent '(' (ident (',' ident)*)? ')'
A sub-process call references another process declared in the same
file. The argument list is currently restricted to identifiers.
Parentheses are always required — even for empty argument lists (Skip
and Div are the only bare uppercase atoms):
proc Notified() { irq?159 -> Handle_eth(); irq!159 -> Notified(); }
proc Handle_eth() { handle_irq -> Dispatch(); }
proc Dispatch() { [rx] receive -> Skip [] [!rx] cleanup -> Skip; }
proc Reply(pkt: int) { o2d!pkt -> Skip; }
The validator confirms each ProcessRef resolves to a declared process
and that the argument count matches.
Empty processes
Skip and Div are atomic and self-contained: Skip is successful
termination, Div is divergence (a self-loop):
proc NoOp() { Skip; }
proc Stuck() { Div; }
Limitations
- Argument lists for
ProcessRefand computation-event references are restricted to identifiers. Onlyirq?Nandirq!Ntake an integer literal. - Currently only variable declarations (
x: int;) are permitted as inline body items alongside process expressions. Assignment statements and external calls must live inevtdeclarations. This restriction is planned to be lifted: future versions will allow statements directly inprocbodies, with flexible interleaving of statements and process expressions. - Recursion is modeled as a sub-process call by name, in tail position only (see Recursion).
- A receive binder does not reach a referenced process: pass it as an
argument,
c?x -> Drain(x)withproc Drain(x: T)(see Scopes). An entry point (@bind) takes no parameters.