Back to the 2026 paper

Module 3: Semantic Analysis, Symbol Table, Run-time environment

20267m

Explain the structure of an activation record and its role during procedure execution.

Worked SolutionAI Assisted

Activation record (stack frame)

An activation record is the block of memory pushed on the run-time stack each time a procedure is called. It holds everything one activation of the procedure needs. Records are pushed on a call and popped on return, so the stack mirrors the chain of active calls.

Structure of an activation record

SVGVector Architecture Diagram (SVG)
lower address Returned value Actual parameters Control link (dynamic link) Access link (static link) Saved machine status Local variables Temporaries higher address <- fp
Field Purpose
Returned value Space where the callee stores its result for the caller
Actual parameters Arguments supplied by the caller
Control (dynamic) link Points to the caller's activation record, so the stack can be unwound on return
Access (static) link Points to the record of the lexically enclosing procedure, used to reach non-local variables
Saved machine status Return address and the register contents of the caller, restored on return
Local variables Data declared inside the procedure
Temporaries Intermediate values of expression evaluation

Role during procedure execution

  1. Call sequence. The caller evaluates and stores the actual parameters and the return address; the callee saves registers, sets the frame pointer fp, and allocates space for locals and temporaries.
  2. Execution. Local variables are accessed at a fixed offset from fp. Non-local variables are reached by following access links (static scope) the required number of levels, then adding the offset. Global variables live in static memory with a fixed address.
  3. Return sequence. The callee stores the return value, restores the saved registers and fp, pops its record, and jumps to the return address.
  4. Recursion. Every call gets its own record, so each recursive activation has its own copy of locals and parameters.

Accessing variables: for a local x use [fp + offset_x]. For a non-local y declared kk nesting levels up, follow the access link kk times to that procedure's record, then use [record + offset_y].

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.