← Protocols Interviews

Interview Question · Concept

Exclusive Accesses and the Monitor

L2 Mid-LevelL3 Senioraxiexclusiveatomics

The Question

The interviewer asks

Explain how an AXI exclusive read and exclusive write implement a lock, and what EXOKAY and OKAY mean on each.

Reveal the Model Answer

The manager does an exclusive read. A subordinate that supports exclusives records the address and ID in a monitor (a small tracker) and answers EXOKAY. Later the manager does an exclusive write with the same ID, address and attributes. If no one wrote the location meanwhile, the write happens and gets EXOKAY. Otherwise the write is dropped and gets OKAY, and software retries. The bus is never locked in between.

Two Exclusive Writes, One Monitor EachEdges 11 to 21 of the race: B's write (ID 2), then A's (ID 1). The memory's readies are 1 throughout.
AWVALIDWVALIDBVALIDBRESPManager portA is ID 1, B is ID 2Memoryone monitor per IDAB

The slots are the monitors for A and B; a successful exclusive write clears both.

012345678910clkawvalidawid2x1xwvalidwdataxbxaxbvalidbrespmon1100
  1. Cycle 0

    B's exclusive write address arrives (AWID 2). Both monitors watch 0x600.

  2. Cycle 1

    B's data lands. The monitor for ID 2 matches: the word is written and every monitor on 0x600 is cleared.

  3. Cycle 4

    B is answered: BRESP 1, EXOKAY.

  4. Cycle 5

    A's exclusive write address arrives (AWID 1). No monitor for ID 1 is left.

  5. Cycle 6

    A's data arrives and is dropped.

  6. Cycle 9

    A is answered: BRESP 0, OKAY. For an exclusive write that is failure.

A monitor that still holds gives EXOKAY and a write; an empty one gives OKAY and nothing.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Mid-Level)

A good mid-level answer describes the sequence: exclusive read, monitor, exclusive write. It says OKAY on the exclusive write means it failed.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

What IfProve ItBreak ItCompare

  1. Exclusive Accesses and the Monitor
  2. What IfExclusives to a Subordinate That Lacks ThemL2 Mid-Level

    A manager runs an exclusive sequence against a subordinate with no exclusive monitor. What happens on each step?

    Reveal the Model Answer

    The exclusive read returns OKAY instead of EXOKAY: the data is valid, but nothing is monitored. If the manager writes anyway, the exclusive write also gets OKAY. The location is updated as a normal write, so a lock "fails" yet changes memory. The spec recommends treating OKAY on the read as "not supported" and skipping the write.

    Self-Check

    Tick each key point you covered in your answer.

    Missed Corner

    "The write gets OKAY, so it failed and memory is unchanged."

    Only a subordinate with a monitor drops a failed exclusive write. One without support writes the location and still answers OKAY.

    Source AMBA AXI Protocol Specification IHI 0022L §A6.3.4 Exclusive access from the perspective of the Subordinate

  3. Break ItA Spinlock That Trusts OKAYL2 Mid-LevelL3 Senior

    Break it: a spinlock routine treats any non-error response to its exclusive write as success. What can happen?

    Reveal the Model Answer

    On a memory without an exclusive monitor, both steps return OKAY, so two cores can both believe they hold the lock. On a memory with a monitor, OKAY on the exclusive write means it failed and nothing was written. Either way, only EXOKAY means success. The routine must retry on OKAY, or report that exclusives are not supported.

    Self-Check

    Tick each key point you covered in your answer.

    Spec Misquote

    "OKAY means success, so the lock is taken."

    For an exclusive write, OKAY means the exclusive failed or is not supported. Only EXOKAY means the write succeeded.

    Source AMBA AXI Protocol Specification IHI 0022L §A6.3.2 Exclusive access from the perspective of the Manager

  4. Break ItTesting an Exclusive MonitorL3 Senior

    You are verifying a memory controller's exclusive monitor. Which scenarios do you make sure you hit?

    Reveal the Model Answer

    Races: two managers on one address must give exactly one EXOKAY, and a normal write in between must fail the sequence. ID handling: reusing the ID on a new address moves the monitor. A size or length mismatch between the read and the write may fail the write. Granule: the monitor may watch a wide block, so a write to a neighbouring byte may legally fail the sequence. Limits: test unaligned, non-power-of-two and over-16-beat exclusives too.

    Self-Check

    Tick each key point you covered in your answer.

    What Interviewers Listen For (Senior)

    A good senior answer lists races, interfering writes, ID reuse, mismatched attributes and the monitor's block size. It knows which results the spec leaves to the design.

  5. CompareExclusives Against AXI5 AtomicsL3 Senior

    Why did AXI5 add atomic transactions when exclusives already existed?

    Reveal the Model Answer

    An exclusive pair needs two round trips, and it can fail and retry under contention. The data also travels to the manager and back. An atomic transaction sends the operation to the data instead. The subordinate or a near-memory agent does the read-modify-write in one transaction, so the location is unavailable for less time. The cost is ALU logic at the target and a more complex protocol.

    Self-Check

    Tick each key point you covered in your answer.

  6. Prove ItSolve P2.13.1: An Exclusive MonitorSimulator-graded

    Show it, don't just say it: this Silicon Lab problem is graded by the simulator.

    Open Problem P2.13.1

What People Get Wrong

Common wrong answers and why they fail.

Misconception

"OKAY on the exclusive write is fine; OKAY is success."

For an exclusive write OKAY means it failed and memory was not updated. Only EXOKAY is success.

Source AMBA AXI Protocol Specification IHI 0022L §A3.3.1 Write response, Table A3.28; §A6.3.2

Misconception

"Exclusive access locks the bus until the write."

That was AXI3 locked access. Exclusives keep the bus open, and the monitor detects interference after the fact.

Source AMBA AXI Protocol Specification IHI 0022L §A6.3 Exclusive accesses

Learn It, Then Prove It