By grading it against levels that are defined by what the answer contains, not how confident it sounds. The rubric below is the one this Part's question bank uses. Each level adds one kind of content from the answer framework; none can be reached by more vocabulary alone. On this scale the weak answer in that lesson is a 1 and the strong answer is a 4.
Level | Contains | What it sounds like (two cores write X at once) |
|---|---|---|
0 | Wrong or vague: a claim that breaks an invariant, or no mechanism at all | "Both writes go through and the caches merge them." (Two writers at once.) |
1 | Vocabulary only: correct terms, no mechanism | "MESI invalidates the other copy, so it's coherent." |
2 | Correct mechanism: who serializes, which states, who supplies data | "H accepts C0's GetM first, queues C1's, invalidates C1, grants C0. Then forwards to C0, and C1 gets Data(1) with M." |
3 | Mechanism plus a trade-off and one edge case handled explicitly (a race when the question involves concurrency; otherwise a boundary case such as E beside I, a silent E store, or legally stale memory) | Adds: "C1 gets the Inv while in SM^D, so it needs data, not permission. Queueing at H costs a slot; NACK and retry needs a fairness rule." |
4 | Level 3 plus stated assumptions and evidence | Adds: "Assuming MSI, directory, no FIFO, acks at H, both in S. I'd assert SWMR, check the value order 1 then 2 in a scoreboard, and cover Inv in SM^D." |
Two rules keep the rubric honest. First, an error caps the score at 0: an answer that lets two caches write at once has not understood the question, however much else it says. Second, level 4 needs both assumptions and evidence: a perfect mechanism with no stated model cannot be checked against the system the interviewer meant, and an answer with no evidence cannot be checked at all.
Before speaking, jot the points you will make and tag each with its framework part. The scorer below turns that outline into a score with the rules above. Mechanism needs both who serializes and who supplies data; an assumption point needs the protocol plus at least one of home, ordering or delivery. The edge-case point may be tagged race or edge: the scorer accepts either.
import itertools
def score(outline):
"""outline: list of (tag, text). Returns 0 to 4."""
tags = [t for t, _ in outline]
if not outline or "error" in tags:
return 0
mechanism = {"mech:serialize", "mech:data"} <= set(tags)
if not mechanism:
return 1 if "vocab" in tags or any(t.startswith("mech:") for t in tags) else 0
if not ("tradeoff" in tags and ("race" in tags or "edge" in tags)):
return 2
assumptions = {t for t in tags if t.startswith("assume:")}
if "assume:protocol" in assumptions and len(assumptions) >= 2 and "evidence" in tags:
return 4
return 3
def score_broken(outline):
"""Variant that forgets the assumption requirement for level 4."""
tags = [t for t, _ in outline]
s = score(outline)
return 4 if s == 3 and "evidence" in tags else s
strong = [
("assume:protocol", "MSI, directory at H"),
("assume:ordering", "no FIFO, acks at H, both start in S / 0"),
("mech:serialize", "H accepts C0 GetM first, C1 GetM queued"),
("mech:data", "C1 invalidated in SM^D, later gets Data(1) with M via Fwd-GetM"),
("race", "Inv reaches C1 while its own GetM is pending"),
("tradeoff", "queue slot at H versus NACK and retry with fairness"),
("evidence", "SWMR assertion, scoreboard value order 1 then 2, cover Inv in SM^D"),
]
vocab_only = [("vocab", "MESI"), ("vocab", "invalidation"), ("vocab", "coherent")]
no_assumptions = [p for p in strong if not p[0].startswith("assume:")]
wrong = strong + [("error", "both caches hold M and merge the writes")]
assert score(strong) == 4
assert score(vocab_only) == 1
assert score(no_assumptions) == 3 # mechanism without a model cannot reach 4
assert score(wrong) == 0 # an invariant-breaking claim caps the score
edge_not_race = [p for p in strong if p[0] != "race"] + [("edge", "C1 in E beside C0 in I: silent E-to-M store, no message")]
assert score(edge_not_race) == 4 # a boundary case counts as the edge case when no race applies
# General claim: over every subset of the strong outline, a 4 requires assumptions and evidence,
# and adding a point never lowers the score.
for n in range(len(strong) + 1):
for subset in itertools.combinations(strong, n):
s = score(list(subset))
tags = {t for t, _ in subset}
if s == 4:
assert "assume:protocol" in tags and "evidence" in tags
for extra in strong:
if extra not in subset:
assert score(list(subset) + [extra]) >= s
# Failing case: the broken scorer gives a 4 to an outline with no assumptions.
assert score_broken(no_assumptions) == 4
print("PASS: strong outline scores 4, vocabulary scores 1, no assumptions cannot reach 4")The enumeration checks the rubric's structure, not one example: across all 128 subsets of the strong outline, a 4 always contains a protocol assumption and evidence, and adding a correct point never lowers the score. The broken scorer shows the failure the rule prevents: without the assumption requirement, a fluent mechanism with a test plan would be graded 4 while leaving the model unstated.
Grade each answer to "What happens when two cores write the same line at the same time?" before opening the check below. The answers are illustrative.
"The cache coherence protocol serializes them. One gets M and the other is invalidated. That's what SWMR means."
"Assuming MSI on a directory: H accepts C0's GetM first and queues C1's. C1 is invalidated while in SM^D, so when it is served it needs the data; H forwards to C0 and C1 gets Data(1) with M. Queueing costs a slot at H, retries would need fairness."
"On a snooping bus, both caches arbitrate and the bus picks one. The winner's request is seen by the other, which invalidates. The loser then reissues its GetM and gets the line from the winner's cache, which has the newest value. I'd prove it with an assertion that at most one cache is in M."
Answer 1 scores 1: correct vocabulary, but no serialization point and no data source. It needs the mechanism (who orders, what the loser receives). Answer 2 scores 3: assumptions stated in part, full mechanism, one race (Inv in SM^D) and a trade-off, but no evidence. One sentence of checks (SWMR assertion, value order in a scoreboard, coverage of Inv in SM^D) makes it a 4. Answer 3 scores 2: the snooping mechanism is right in outline (the bus order is the serialization point, see Snooping on a Shared Bus) and it has evidence, but no trade-off and no race or edge case handled; its assumption is only implied by "on a snooping bus" and says nothing about the protocol. Evidence does not lift a score past a missing level.
Because the trace it describes is correct only under some model. Under acks at the requester, an ordered bus or a NACKing home, the messages and states differ. The interviewer cannot confirm the answer is right for their system, so the rubric withholds the top level until the assumptions are stated.