Appendix A — Glossary
Winter Semester 2026/2027
Short definitions of terms that the chapters use precisely. Each entry names the lecture where the term first matters. Terms that are easily confused point to each other with see also.
- Architectural state
-
State that the ISA defines and that every implementation must provide, as opposed to details of the microarchitecture. The
xregisters, the CSRs and thepcare all architectural state. Thepcdiffers from the others in one respect: it is not addressable. No instruction names it as an operand or stores it to memory; it changes only through control transfers and the trap rule. See also: program counter, livepc. (Lecture 5) - Automatic storage duration
-
The lifetime of an ordinary local variable, declared inside a function without
static. The object exists only while that call is active and lives in the call’s stack frame; every call, including a recursive one, gets its own copy. When the call returns, or when its stack frame is reused, the object is gone. Example:struct process p;insidemain()in Exercise 2 lies inmain()’s stack frame at the top of the OS stack. See also: static storage duration. (Lecture 4) - Bootstrap function
-
The internal function through which a process is entered for the first time:
process_start(). It calls the process’s entry function and, if that returns,process_exit(0). The initial saved state of a new process points to it, asrain the CP1 context and aspcin the trap frame. (Lecture 3) - Caller and callee
- In a function call, the caller is the function that makes the call, the callee the function being called. The calling convention splits the work of preserving registers between them. See also: calling convention, caller-saved and callee-saved register. (Lecture 3; named explicitly in Lecture 5)
- Caller-saved and callee-saved register
-
A callee-saved register is one whose value a called function must preserve for its caller:
spands0–s11. A caller-saved register may be destroyed by a call, so the caller keeps any value it still needs elsewhere:t0–t6anda0–a7, andra, which every call overwrites. The split is why CP1’scontext_switch()could save onlyra,spands0–s11. See also: calling convention. (Lecture 3) - Calling convention
-
The software agreement, defined in the RISC-V ABI, that lets separately compiled functions cooperate about how registers are used: arguments in
a0–a7, the return value ina0, the return address inra, and which registers are caller-saved or callee-saved. The compiler guarantees it for the code it generates; hand-written assembly must keep it itself, and the hardware knows nothing of it. A trap is not a call, so the convention gives no guarantee at a trap. (Lecture 3) - CLINT (core-local interruptor)
-
The timer device of QEMU’s
virtmachine, a part of the platform, not of the CPU. It holds the memory-mapped registersmtimeandmtimecmpand requests a machine timer interrupt from the CPU whilemtime >= mtimecmp. Newer RISC-V documents call it ACLINT. See also:mtimeandmtimecmp, platform. (Lecture 6) - Context
-
The saved CPU register state needed to continue the same execution. The CP1
struct contextholdsra,spands0–s11, which suffices at a call boundary. From Lecture 5 the trap frame is the context, complete for our model. See also: trap frame, context switch. (Lecture 3) - Context switch
-
In CP1: save the current execution’s context, restore another saved context, and continue the restored execution.
context_switch()did both halves in one function called by the running code; from Lecture 5 the trap path saves and the return path restores. (Lecture 3) - Continuation address
-
A saved value saying where an execution continues when it is restored. It is never the live
pcitself. In CP1 it israin the context; in the trap frame it is the fieldpc. After an interrupt it equals the trappc; after anecallit is the trappc+ 4. See also: livepc, trappc. (Lecture 4) - Control and status register (CSR)
-
A CPU register outside the general-purpose registers
x0–x31, reachable only through the CSR instructions of theZicsrextension, not through loads and stores. Our trap mechanism uses five:mtvec(where traps enter: a base address and a mode field),mepc(the trappc),mcause(the reason, with the interrupt bit in bit 63),mstatus(among othersMIE,MPIE,MPP), andmscratch(no meaning for the hardware; our OS keeps the current frame’s address there). Lecture 6 addsmie(one enable bit per interrupt source, among themMTIEfor the machine timer) andmip(the pending bits, among themMTIP). The prefixmmeans machine mode. (Lecture 5; Lecture 6) - Cooperative and non-cooperative entry
-
An entry into the OS is cooperative if the running execution itself decides to make it, as with
process_yield()in CP1 orecallin Lecture 5. It is non-cooperative if the OS is entered without the execution’s intention, as with an illegal instruction or, from Lecture 6, a timer interrupt. This axis is separate from synchronous versus asynchronous: an illegal instruction is synchronous but not cooperative. See also: synchronous and asynchronous trap, preemption. (Lecture 3; Lecture 5) - Cross-compilation
- Building code on one architecture for another. A cross compiler runs on the development host, an x86-64 or ARM machine, and produces RV64 code for the target. (Lecture 1)
- Development host
-
The machine on which the development tools run: in BVS1 the Ubuntu
bvs1VM. See also: physical host, target. (Lecture 1) - ELF (Executable and Linkable Format)
- The binary file format we use for both object files and the final executable. An ELF file contains sections, a symbol table and the entry address. (Lecture 1)
- Exception
-
A synchronous trap: caused by the instruction being executed, at the same instruction every time the program runs with the same input. The trap
pcis that instruction. Examples:ecall(mcause11 from machine mode), illegal instruction (mcause2). Not an interrupt. See also: interrupt, trap. (Lecture 5) - Execution
-
A running sequence of instructions together with the CPU and memory state it needs to continue. Two executions take turns when one stops and another continues; a process is an execution that the OS manages. In CP1
main()was an execution too, suspended while the process ran; from Lecture 5 nothing of the OS remains suspended between traps. See also: process. (Lecture 2) - Exit
-
The process finishes, records a result, and returns control to the operating system; it must never continue. From Lecture 5
process_exit()makes the system callexit. See also: yield. (Lecture 2; Lecture 3) - Idle process
-
The process the OS runs when no other process is
READY. In the reference implementation it is a loop aroundwfi(wait for interrupt); after the last process has exited, the OS returns into its frame. (Lecture 5) - Immediate
-
A value small enough to be encoded inside an instruction, for example in
lioraddi. Larger values may need several instructions. (Lecture 4) - Instruction Set Architecture (ISA)
- The contract between software and a processor: the instructions, registers and behaviour that every implementation provides and that software may rely on. The trap rule and the CSRs belong to it. See also: microarchitecture, platform. (Lecture 1)
- Interrupt
-
An asynchronous trap: caused by an event independent of the current instruction and taken between two instructions, so the place varies from run to run. The trap
pcis the instruction that was about to execute and has not executed yet; there is no+4. Interrupts are taken only when enabled; on a trap the CPU disables them while the OS saves the process’s state. Not an exception: anecallis not an interrupt. See also: exception, pending, timer interrupt, trap. (Lecture 4; as a kind of trap in Lecture 5) - Label
-
A name in assembly source, written as
name:, that names the position of the next instruction or data item. Labels exist only in source code. The assembler turns a named label such as_start:ortrap_entry:into a symbol; a local label such as1:instart.Sis used only within its file and does not appear in the symbol table.trap_entry:intrap.Snames the first instruction of the trap path. Not to be confused with an output label, the constant text that a program prints before a value, such as"process: result: ". See also: symbol. (Lecture 2) - Lifecycle state
-
Says whether an execution may run:
READY,RUNNINGorFINISHED. The context says how it continues. (Lecture 3) - Linker
- The tool that combines object files, resolves references between them by symbol name, and places their sections at final addresses in target memory. (Lecture 1; Lecture 2)
- Linker script
-
The file that tells the linker where the sections go in target memory and defines symbols such as
_stack_top. Ours islinker.ld; students read it but do not write one. (Lecture 2) - Live
pc -
The current execution position of the CPU: the
pcas architectural state. Software never stores it directly; the CPU copies it intomepcon a trap, andmretsets it frommepc. See also: trappc, continuation address. (Lecture 4; named in Lecture 5) - Machine mode
-
The most privileged RISC-V privilege mode (M-mode). Our whole system, OS and processes alike, runs in it, which is why our CSRs carry the prefix
mandecallproducesmcause11. See also: privilege mode. (Lecture 5) - Memory-mapped register
-
A device register that has an address in the same address space as RAM, so that an ordinary load or store to that address reads or writes the device instead of memory. In C it is reached through a
volatilepointer, so that the compiler performs every access as written. Examples: the UART’s transmit and status registers at0x10000000and0x10000005,mtimeandmtimecmp. The platform decides which address leads to RAM and which to a device; on QEMUvirt, RAM starts at0x80000000. CSRs are not memory-mapped: they have no address. See also: control and status register. (Lecture 6) - Microarchitecture
- How a particular processor implements the ISA internally, for example its pipeline or caches. Software written for the ISA does not depend on it. See also: ISA. (Lecture 1)
mtimeandmtimecmp-
The two 64-bit memory-mapped registers of the CLINT.
mtime(at0x0200bff8on QEMUvirt) is the current time; the device counts it up from 0 at machine start at 10 MHz, one count every 100 ns, and it never stops.mtimecmp(for hart 0 at0x02004000) holds a point in time, not a duration: whilemtime >= mtimecmp, a timer interrupt is pending.timer_arm(delta)writesmtime + deltaintomtimecmp. See also: CLINT, pending, time slice. (Lecture 6) - Object file
- A target-specific intermediate file produced by the compiler or assembler, in ELF, that still needs to be linked with others into an executable. (Lecture 1)
- Operating system
- Software that helps turn hardware into a usable computer system by providing abstractions, resource management, coordination, protection, and services for programs and users. Two views: the OS as resource manager and the OS as abstract machine. (Lecture 1)
- OS stack
-
The stack on which the OS’s own code runs: the region that the linker script reserves below
_stack_top._startselects it, andmain()has run on it since Lecture 2. From Lecture 5 the trap path switches to it explicitly withla sp, _stack_top, so every handler run starts at its top; anything that must outlive one handler run must not live there. See also: process stack. (Lecture 4) - Pending
-
An interrupt is pending when its source has requested it and the request has not been withdrawn; it is enabled when the CPU’s enable bits allow it, and taken when the CPU applies the trap rule. The machine timer interrupt is pending in
mip.MTIPwhilemtime >= mtimecmp; it stays pending until the OS writes a largermtimecmp, and taking it does not clear it. It is taken only ifmie.MTIEandmstatus.MIEare also set. See also: interrupt,mtimeandmtimecmp. (Lecture 6) - Physical host
- The real computer that provides the CPU, memory and devices, and on which the development VM runs. See also: development host, target. (Lecture 1)
- Platform
-
The machine around the CPU: memory map and devices such as the UART and, in Lecture 6, the timer. QEMU’s
virtmachine is our platform. A platform device raises an interrupt; the CPU’s trap rule reacts to it. See also: ISA. (Lecture 5) - Polling
-
Asking a device again and again whether it is ready, in a loop, until it is.
uart_putc()polls the UART’s line status register before each character. See also: memory-mapped register, UART. (Lecture 6) - Preemption
- The OS takes control without the running process’s cooperation, made possible by a timer interrupt. Interrupt handling and the scheduling decision that may follow are related but distinct steps. In our system from Lecture 6, the timer interrupt enters the OS every time slice; with one process, the scheduling decision returns the same frame. See also: cooperative and non-cooperative entry, time slice. (Lecture 4; Lecture 6)
- Privilege mode
- A CPU mode that determines which instructions, CSRs and memory are available. RISC-V defines machine, supervisor and user mode; a real OS runs processes in a less privileged mode, so that they cannot change OS state. Privilege is outside our model: everything runs in machine mode. See also: machine mode. (Lecture 5)
- Process
- An execution that the operating system can manage. In our system it combines an entry function, owned stack storage, a saved context (from Lecture 5 the trap frame), a lifecycle state and an exit status. See also: execution. (Lecture 2; Lecture 3)
- Process stack
-
The stack of one process: owned stack storage, in our system the array
stackinsidestruct process, whichspselects while the process runs. “Process stack” names the role of the memory, not an ELF section: the array lies wherever the process object lies. See also: OS stack. (Lecture 3; Lecture 4) - Program counter (
pc) -
Identifies the instruction to execute. It is CPU state, not memory, and not one of the general-purpose registers
x0–x31. See also: architectural state, livepc. (Lecture 4) - Pseudoinstruction
-
Assembler notation that is not itself an instruction but is translated into one or more real instructions. Examples:
li,mv,j,ret(jalr x0, 0(ra)), and the CSR formscsrr,csrwandcsrs, which becomecsrrsorcsrrw. (Lecture 5) - QEMU
-
An emulator and virtualizer. It runs as an ordinary program in the development VM and emulates the RV64 target machine; we start it without firmware (
-bios none). (Lecture 1) - Resume
- Continue a paused execution where it stopped, as opposed to starting it again from its entry function. From the CPU’s point of view, resuming and starting a process are the same operation: a return into a saved frame. (Lecture 3)
- Return path
-
The second half of the provided
trap.S, from the labelos_starttomret: it makesmscratchpoint to the frame it restores, writes the frame’spcintomepc, loads the registers and executesmret. It has two ways in: after every trap, by falling through fromcall trap_handler, and once fromos_run()for the first start. See also: trap path. (Lecture 5) - Return-address register
-
ra(x1): acallstores the location to which execution returns, andretjumps there. It is the continuation of a call. (Lecture 3) - RV64
-
The 64-bit form of RISC-V, the ISA of our target. We build for
rv64imac_zicsr: the base integer instructions, multiplication and division, atomics and compressed instructions, plus the CSR instructions. (Lecture 1) - Section
-
A named part of an object file or executable that groups content of one kind; the linker places sections in memory according to the linker script.
.textholds instructions,.rodataconstant data,.datainitialised data, and.bsszero-initialised data, which takes no space in the file. (Lecture 2) - Stack
-
Runtime memory for the data of active function calls: saved call information, saved registers, local variables. Function instructions remain in
.text. A stack grows toward lower addresses. See also: stack frame, OS stack, process stack. (Lecture 2; Lecture 3) - Stack frame
-
The call data of one active call on a stack, for example its saved
ra, saved registers and local variables. Not a trap frame. See also: trap frame. (Lecture 4) - Stack pointer (
sp) -
Register
x2; selects the current position in the stack in use. Which stack is in use is decided by the value insp: a trap does not change it. (Lecture 2; Lecture 4) - Static storage duration
-
The lifetime of global variables and of variables declared
static, also inside a function. The object exists exactly once, for the whole run, independent of any stack frame and of which functions are active; it is initialised once, before the program runs. Its section depends on the initial value:.bssfor no initialiser or zero,.datafor a non-zero initialiser,.rodataforconstdata.staticinside a function changes only where and how long the object lives; the name stays visible only inside that function. Example:static struct process p;inmain()lies in.bssand survives every trap. See also: automatic storage duration. (Lecture 4;static pin Lecture 5) - Symbol
-
An entry in the symbol table of an object file or an ELF file: a name with a value, usually an address, plus a type and a visibility.
nm -nlists the symbols of a program sorted by address. Symbols come from labels in assembly, from C functions and from C variables with static storage, for which the compiler emits labels, or from assignments in the linker script. Example:trap_entrycomes from a label,mainfrom a C function,_stack_topfromlinker.ld. The linker resolves references between separately translated parts by symbol name, and fixes the final address of every symbol when it places the sections. See also: label. (Lecture 2;nm -nin Lecture 4) - Synchronous and asynchronous trap
- A synchronous trap is caused by the instruction being executed and is reproducible: an exception. An asynchronous trap is caused by an event outside the instruction stream and is taken between two instructions, wherever the program happens to be: an interrupt. See also: exception, interrupt, cooperative and non-cooperative entry. (Lecture 5)
- System call
-
A request to the OS made with
ecall. In our conventiona7selects the service,a0anda1carry arguments, and the OS may return a result ina0:exitis 0,yieldis 1. The system call is the request, not the C function that makes it:process_yield()makes the system callyield. (Lecture 5) - Target
- The machine for which we build the program: an RV64 machine, emulated by QEMU. See also: development host, physical host. (Lecture 1)
- Tick
-
One timer interrupt of the OS, as in the Exercise 5 library’s lines
os: tick N at <pc> in process 1. Not one count ofmtime: that is whytimer_arm()takes adeltaand the time slice is calledTIME_SLICE, both inmtimecounts. See also: time slice, timer interrupt. (Lecture 6) - Time slice
-
How long the OS lets a process run until the next timer interrupt; other books call it a quantum. In our system 10 ms,
TIME_SLICE=TIMER_HZ / 100= 100,000mtimecounts. See also: tick, preemption. (Lecture 6) - Timer interrupt
-
An interrupt raised by the platform’s timer when a programmed time is reached (
mcause7 with the interrupt bit set). It lets the OS regain control without a voluntary yield. In our system the CLINT requests it whenmtimereachesmtimecmp; the trappcis the instruction not yet executed, and the handler re-arms the timer before it returns a frame. See also: pending, tick. (Lecture 4; implemented in Lecture 6) - Toolchain
- The set of cooperating build tools: compiler, assembler and linker, here for the RV64 target. (Lecture 1)
- Trap
-
A transfer of control to an OS-defined handler that the CPU performs itself. On a trap the CPU records where (
mepc) and why (mcause), turns interrupts off (MPIE <- MIE,MIE <- 0) and jumps tomtvec. The umbrella term for exceptions and interrupts. See also: exception, interrupt, return path. (Lecture 5) - Trap frame
-
The complete saved integer context of an execution that trapped, as our teaching model requires it:
struct trap_frame, with the 31 writable integer registers inregs[1]–regs[31]and the continuation address inpc. It is the fieldframeofstruct process, not on any stack; the name comes from systems that push it onto a stack. See also: stack frame, context. (Lecture 5) - Trap handler
-
The OS code that runs after a trap. In the course it is the C function
trap_handler(), which the trap path calls with the frame of the process that trapped and which returns the frame to restore: the same one to resume, another one to schedule. In lifetime diagrams, “handler” labels the whole OS run between a trap and a return. See also: trap path, return path. (Lecture 5) - Trap path
-
The first half of the provided
trap.S, from the labeltrap_entrytocall trap_handler: it saves all registers and the trappcinto the frame thatmscratchpoints to, switches to the OS stack and callstrap_handler(). The CPU jumps to it viamtvec; nobody calls it. See also: return path. (Lecture 5) - Trap
pc -
Course term, not a RISC-V name: the
pcvalue that the CPU records inmepcon trap entry. For an exception it is the causing instruction, for anecalltheecallitself; for an interrupt it is the next instruction, not yet executed. See also: livepc, continuation address. (Lecture 5) - UART
-
The serial device of our platform through which all output of the course is printed; on QEMU
virtits registers start at0x10000000.uart_putc()polls its line status register and stores each character into its transmit register, with ordinary loads and stores. See also: memory-mapped register, polling, platform. (Lecture 6) - Yield
-
The running process voluntarily returns control to the operating system while remaining able to resume later. From Lecture 5
process_yield()makes the system callyield. See also: exit. (Lecture 2; Lecture 3)