Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Event Declarations

EventDecl   ::= 'evt' ident Carriers? ':' Body
Body        ::= Statement | '{' Statement* '}'
Carriers    ::= ('.' '|' Param (',' Param)* '|')+
Param       ::= ident ':' Type

An event declaration introduces one named atom of computation at the top level of a .fi file using the evt keyword. Processes reference it by name on the left of a prefix (my_event -> ...).

evt declarations and proc definitions may appear in any order in a .fi file: a process can use an event declared below it.

Computation events are one of three event kinds in CoreFi (paper §4.2); the other two — channel events (c?x / c!e, or c? / c!) and hardware-interrupt events (irq?N / irq!N) — are inline atoms that appear in process bodies and have no top-level declaration.

Computation events

A computation event is a named, atomic block of statements: assignments and external calls, plus optional carrier parameters. The block executes as a single transition in the labelled-transition system — processes can prefix on it (my_event -> ...) but cannot observe it mid-flight.

Names follow snake_case by convention, which sets a computation event reference apart from a sub-process reference (UpperCamelCase, with parentheses). The parser accepts any identifier as an event name.

Body

After the :, the body is either one statement (a local variable declaration, an assignment, an external function call or debug output), ending at its ;, or any number of statements in braces. Either way the body ends where it says, so what follows it is never read as part of it: a global declared below an event stays a global.

// One statement: no braces, ends at its ;
evt setup_eth: eth.eth_setup();

// Several statements: braces.
evt handle_packet.|size: int|: {
    local_buf: int;
    local_buf = eth.alloc(size);
    counter = counter + 1;
}

Debug output

A dbg(...) statement prints values from an event body; see Debug Output.

Carriers

evt handle_packet.|size: int|:                  // single carrier
evt ack.|chan: int, slot: int|:                 // grouped carriers
evt ack.|chan: int|.|slot: int|:                // chained carriers (equivalent)

Carriers are parameters supplied by the invoking process. The syntax uses pipes (.|...|) — chosen over parentheses so the visual boundary is distinct from sub-process parameter lists. Multiple carriers may be grouped in a single .|x: int, y: int| clause or chained across multiple .|x: int|.|y: int| clauses; both forms behave identically.

Inside the body, carriers are read like any other variable: passed to external calls (eth.handle_rx(idx)) or read in expressions (local_buf = eth.alloc(size)). They are read-only; assigning one is an error. Three kinds of variable names can appear in an event body:

KindDeclared inWritable
GlobalTop-level of the .fi fileyes
CarrierThe event’s `.name: type
LocalInside the body via name: Type;yes

An event sees its own locals and carriers, then the program’s globals and the system’s constants, never a process variable; lookup and shadowing are in Scopes. To carry mutable state across event invocations, use a global; to carry mutable scratch within one invocation, declare a local variable.

Referencing an event

EventRef ::= ident ('.' ident)*

A process runs an event by naming it, followed by one .ident per carrier, by convention without whitespace around the dots. The identifiers are the process’s own variables (a parameter, a receive binder, a declaration or a global), supplied in the order the event declares its carriers:

evt forward.|pkt: Slot|: { ... }
evt ack.|chan: int, slot: int|: eth.ack_slot(chan, slot);

proc Relay(pkt: Slot, c: int, s: int) {
    forward.pkt -> ack.c.s -> Skip;
}

Examples

// No carriers — the event is a fixed call.
evt setup_eth: eth.eth_setup();

// Single carrier, single-statement body — idx is the carrier.
evt read_frame.|idx: int|: eth.handle_rx(idx);

// Several statements, in braces — size carrier passed to alloc.
evt handle_packet.|size: int|: {
    local_buf: int;
    local_buf = eth.alloc(size);
    counter = counter + 1;
}

// Multiple carriers, grouped form.
evt ack.|chan: int, slot: int|: eth.ack_slot(chan, slot);

// Same event, chained carrier form (equivalent).
evt ack.|chan: int|.|slot: int|: eth.ack_slot(chan, slot);

Empty-body events

evt noop: {} is an event with no statements. Useful as a placeholder while a process expression is being prototyped.

Channel events

ChannelEvent ::= ident '?' ident?            // c?x / c? — receive
              |  ident '!' Expr?             // c!e / c! — send

A channel event is an atomic communication action between two protection domains. The channel name on the LHS is resolved against the Chan declarations in the surrounding .fis.

Channel events appear inline inside process expressions — they have no top-level declaration.

A message-passing channel carries a value: a buffered channel (via r<T>) or a Sync Chan<T>, whose type T is the value’s. On it the receive form c?x binds the incoming value to x for the rest of that prefix only (c?x -> P): the binder is gone at the next ;, and a referenced process does not see it unless it is passed as an argument (c?x -> Drain(x)). The send form c!e transmits the expression e, of type T. A signalling channel is a Microkit notification, which carries no value: its events are c? and c!, and a value or binder on it is an error (channel 'ball' carries no value), as is leaving one off a message-passing channel.

No selective receive

The RHS of ? is always a single identifier (a binder), never a value pattern. Traditional CSP / CSP# accepts c?ACK as “wait only for the message ACK”, but Fiducia rejects this: it can deadlock when no sender ever produces the matching value, conflicting with CoreFi’s deadlock- freedom story (paper §4.1 Wf1). The same expressiveness is recovered by binding then guarding:

// Recommended.
c?msg -> ([msg == ACK] handle_ack -> Skip [] [msg == NACK] handle_nack -> Skip default Skip)

Send-payload style

The RHS of ! accepts any Expr — the parser does not reject a call expression there today. The recommended style is still to keep channel events as pure-communication atoms: bind a call’s result in a computation event first, then send the bound variable, rather than calling directly in send position. This keeps side-effecting work legible as its own step in the process algebra, even though the grammar itself doesn’t enforce it:

// Discouraged (parses, but buries a side-effecting call in a
// communication event):
// c!eth.get_packet()

// Recommended: bind, then send (pkt is a global variable).
evt get_pkt: pkt = eth.get_packet();
proc P() { get_pkt -> c!pkt -> ... }

Hardware-interrupt events

IRQEvent ::= 'irq' '?' integer_literal       // irq?N — await
          |  'irq' '!' integer_literal       // irq!N — acknowledge

A hardware-interrupt event is a special-cased channel event on the reserved channel name irq. The integer is the IRQ number declared on the protection domain. irq?N blocks until the IRQ fires; irq!N acknowledges the IRQ back to the kernel. The literal is not checked against the IRQ the protection domain declares: a mismatch is not reported.

Like channel events, IRQ events appear only inside process expressions and have no top-level declaration:

proc Notified() { irq?159 -> Handle_eth(); irq!159 -> Notified(); }

🚧 self.IRQ syntax is planned — irq?self.IRQ / irq!self.IRQ will resolve the protection domain’s IRQ number without a magic literal.