FreeExam

Software engineer: Concurrency and State Correctness

Original interview scenarios on atomicity, publication, ownership, lock and wait protocols, cancellation, reentrancy, concurrent histories, resource lifetimes, and progress guarantees.

These prompts are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.A counter starts at 5. Under a supplied interleaving, two threads each atomically read 5, compute 6 locally, then each atomically write 6. No operation combines read and update. What is the final counter value?

    Show answer and explanation
    1. 11
    2. 7
    3. 5
    4. 6

    Answer: 6

    Both writes store 6. Individually indivisible reads and writes do not make the whole read-compute-write sequence one atomic increment; this interleaving loses one intended increment.

  2. 2.An atomic fetch-and-increment returns the old value and increases the counter by one as one indivisible operation. Starting at 5, two calls complete with no other access. Which returned values occur, in some order?

    Show answer and explanation
    1. 5 and 5
    2. 5 and 6
    3. 7 and 7
    4. 6 and 7

    Answer: 5 and 6

    The first operation returns 5 and leaves 6; the second returns 6 and leaves 7. Which caller gets which value depends on order, but their returned values are distinct under the supplied operation.

  3. 3.Two atomic fields represent an interval. A writer changes (low,high) from (0,10) to (20,30) by storing low first. A reader can run between stores. What does individual-field atomicity fail to guarantee?

    Show answer and explanation
    1. The existence of an order for the supplied steps
    2. The writer's ability to express the target values
    3. A consistent pair satisfying the interval invariant
    4. Indivisibility of each specified atomic store

    Answer: A consistent pair satisfying the interval invariant

    The reader can observe low=20 with high=10. Coordinating a multi-field invariant requires an appropriate snapshot or update protocol; separate atomic fields do not establish that pairwise guarantee.

  4. 4.A writer protects updates to a shared pair with a mutex. A reader ignores that mutex and reads the fields separately while updates occur. What protection is missing?

    Show answer and explanation
    1. Only the writer uses the mutex, so that alone guarantees a consistent pair for readers that do not participate in any observation protocol.
    2. A protocol coordinating the reader with the updates
    3. A guarantee supplied by individual field access without coordinating the whole pair
    4. A rule that the reader's later return retroactively locks its earlier reads

    Answer: A protocol coordinating the reader with the updates

    A lock protects through a shared synchronization discipline. Its use on the writer path alone does not establish a consistent reader view when the reader does not participate in a suitable protocol.

  5. 5.In a supplied mutex model, an acquire blocks until the current holder releases it, including when the holder itself calls acquire again. While holding it, a function invokes a callback that immediately acquires that mutex. What can happen?

    Show answer and explanation
    1. The function waits on a release it cannot reach.
    2. The callback releases the caller's mutex before acquiring it.
    3. The nested acquire necessarily succeeds immediately.
    4. The outer holder automatically releases the mutex when it calls any callback.

    Answer: The function waits on a release it cannot reach.

    The caller cannot return from the callback until the nested acquire finishes, while the nested acquire waits for the caller's release. Under the explicitly nonreentrant blocking model, this creates a self-dependency.

  6. 6.Thread A holds lock L and waits for M. Thread B holds M and waits for L. Considering only these blocking locks, what rule would prevent this order cycle?

    Show answer and explanation
    1. An extra retry while retaining the currently held lock
    2. A common acquisition order for both locks
    3. More queued calls to the same blocking paths
    4. A different arbitrary order in each thread

    Answer: A common acquisition order for both locks

    A shared lock order removes this particular circular acquisition pattern. A rule must apply to all relevant paths; repeatedly waiting while retaining conflicting locks does not resolve the cycle.

  7. 7.A function checks a mutable object's version under a lock, releases the lock, waits for an external call, then writes as if the checked version were still current. What must the commit path handle?

    Show answer and explanation
    1. Intervening changes through revalidation or a suitable conditional update
    2. A permanent reservation of state created by reading a version
    3. The original check succeeded, so the observed version remains reserved while the function waits outside the lock.
    4. Only the external operation's successful response

    Answer: Intervening changes through revalidation or a suitable conditional update

    The unlocked interval can contain other updates. An earlier check does not reserve future state; validate the relevant assumptions at the actual local commit boundary under the chosen protocol.

  8. 8.Two callbacks share one event-loop thread. Callback A reads a setting, awaits an operation, and resumes after B changes the setting. Why can A's earlier assumption be stale?

    Show answer and explanation
    1. Only simultaneous CPU execution can invalidate a prior read.
    2. A single thread guarantees every asynchronous function runs to completion without interleaving.
    3. Awaiting automatically restores the earlier setting.
    4. The suspension permits another callback to change shared state.

    Answer: The suspension permits another callback to change shared state.

    Logical interleaving does not require parallel CPU execution. An asynchronous suspension can separate observation from use, so state assumptions need an appropriate lifetime or revalidation rule.

  9. 9.A model guarantees that acquiring a published pointer exposes initialization performed before its release publication. After publication, another thread mutates the object's fields without any further protocol. What does the initial guarantee fail to establish?

    Show answer and explanation
    1. Visibility of initialization covered by the supplied matching edge
    2. The existence of an initially initialized object
    3. The ability to publish a pointer in the model
    4. Safety and consistency of the later concurrent mutations

    Answer: Safety and consistency of the later concurrent mutations

    An initialization-publication guarantee has a specific scope. It does not automatically coordinate later mutable access; use an appropriate update and observation protocol or genuinely immutable state.

  10. 10.A supplied model grants cross-thread initialization visibility only when an acquire observes the corresponding release publication. A reader instead performs a relaxed flag read before using the payload. Which proof step is missing?

    Show answer and explanation
    1. The flag's observed value alone, regardless of the synchronization edge required by the supplied model
    2. The required matching synchronization edge
    3. The number of payload fields written before the relaxed read
    4. A guarantee that every relaxed read is a complete publication protocol

    Answer: The required matching synchronization edge

    Under the stated model, an indivisible flag read is not the specified visibility relationship. Establish the required publication and observation edge rather than infer it from the flag's observed value alone.

  11. 11.A model's acquire guarantee orders subsequent payload access after a matching release publication. A reader loads the payload first and performs the acquire afterward. What ordering must the reader establish?

    Show answer and explanation
    1. Change the payload variable name while preserving its pre-acquire read
    2. Access the payload after the required matching acquire.
    3. Treat a later acquire as retroactive protection of the earlier access.
    4. Repeat relaxed payload reads without the required acquire ordering

    Answer: Access the payload after the required matching acquire.

    The supplied guarantee concerns access ordered after the acquire. A later synchronization operation does not retroactively place an earlier payload access within that guarantee.

  12. 12.A compare-and-swap loop implements increment. On failure, this model replaces expected with the observed value. A candidate of 6 was computed from expected=5, but failure reports 7. What candidate should a correct retry derive?

    Show answer and explanation
    1. 6, retaining the old candidate
    2. 7, without applying the intended increment
    3. 5, restoring the original expected value
    4. 8, from the newly observed 7

    Answer: 8, from the newly observed 7

    The failed attempt did not apply the increment. Recompute from the current observed state under the loop's contract; reusing an obsolete candidate can overwrite newer progress rather than increment it.

  13. 13.An algorithm requires detecting any intervening object replacement. It compares only a pointer value A, which can change A→B→A through address reuse. What information does the final equality lack?

    Show answer and explanation
    1. The ability to compare two pointer representations
    2. The intervening incarnation or replacement history
    3. The existence of a currently stored address
    4. The fact that the current pointer bits equal A

    Answer: The intervening incarnation or replacement history

    A reused address can compare equal after intervening changes. If the algorithm requires detecting that history, its identity and lifetime protocol must supply more than the raw address comparison.

  14. 14.A protocol uses a two-bit version tag to detect intervening updates. Four updates can occur while a reader is paused. What guarantee does the tag alone fail to provide?

    Show answer and explanation
    1. The ability to increment modulo four
    2. A finite set of tag values
    3. A current tag value stored with the object
    4. Unambiguous detection of every intervening update across that pause

    Answer: Unambiguous detection of every intervening update across that pause

    A two-bit tag wraps after four increments. If that many changes can occur while an old observation remains usable, matching tags alone do not establish that no intervening update occurred.

  15. 15.An object is destroyed when its reference count reaches zero. A reader loads an unprotected raw pointer, then tries to increment the count. Another thread can destroy the object between those steps. What must acquisition protect?

    Show answer and explanation
    1. Only the raw pointer's nonzero numerical value
    2. Only an increment performed after loading the raw pointer, even if the object can be destroyed before that increment.
    3. The object's lifetime before the reader accesses its count or fields
    4. Only that the pointer was valid when another thread originally stored it

    Answer: The object's lifetime before the reader accesses its count or fields

    An increment cannot safely acquire ownership through an object that may already have been destroyed. Use a lifetime-safe acquisition protocol that protects the object during the transition to an owned reference.

  16. 16.A supplied memory model destroys objects only when their strong reference counts reach zero and has no cycle collector. Two objects retain strong references to each other after all external references disappear. What remains possible?

    Show answer and explanation
    1. A cycle necessarily corrupts the numerical counter representation.
    2. One object's destruction automatically begins before either count reaches zero.
    3. Both counts must become zero when external references disappear.
    4. The cycle keeps both counts nonzero and prevents destruction.

    Answer: The cycle keeps both counts nonzero and prevents destruction.

    Reference counting under the stated model does not by itself break a strong cycle. Define ownership, weak links, or another reclamation mechanism appropriate to the intended lifetimes.

  17. 17.A queue transfers a reference to a mutable buffer without copying its bytes. After enqueueing it, the producer overwrites the buffer while the consumer may read it. What must the handoff establish?

    Show answer and explanation
    1. Enqueueing the same reference necessarily creates an independent immutable byte copy for the consumer.
    2. A shared length field without an ownership or mutation protocol
    3. A safe ownership or synchronization rule for the shared buffer
    4. A rule that queue order alone prevents later producer writes

    Answer: A safe ownership or synchronization rule for the shared buffer

    Transporting a reference does not make the referred data immutable or privately owned. Coordinate mutation and lifetime, or transfer an appropriate independent representation under the queue's actual contract.

  18. 18.A snapshot copies a list of references but not the mutable objects they reference. Another thread changes one referenced object. What independence does the shallow copy fail to establish?

    Show answer and explanation
    1. The existence of references in both lists
    2. The ability to create a separate list container
    3. Independence of the nested object's state
    4. Copying the outer list also makes every referenced mutable object independent, even though no such object was copied.

    Answer: Independence of the nested object's state

    A separate outer list can still share mutable elements. Snapshot guarantees must account for the depth and lifetime of shared state, not just copying the outer container.

  19. 19.An API returns a read-only view of a mutable object. Its owner can still mutate that object through another alias while clients read the view. What does read-only access through this API fail to guarantee?

    Show answer and explanation
    1. A stable immutable snapshot for the client
    2. The ability to observe some object through an interface
    3. The existence of another alias
    4. A restriction on writes through the supplied view

    Answer: A stable immutable snapshot for the client

    Restricting one access path does not eliminate mutations through other aliases. A stable snapshot needs an appropriate ownership, copying, immutability, or synchronization contract.

  20. 20.A cache method checks for a missing key, releases its mutex, creates an expensive object, then locks again to insert it. Two callers can both pass the check. What uniqueness claim is not established?

    Show answer and explanation
    1. Every check and insertion is individually locked, so there can be only one expensive creation even while both callers compute outside the mutex.
    2. One stored key can be inspected after insertion.
    3. A caller can compute an object outside the mutex.
    4. Only one creation runs for that key.

    Answer: Only one creation runs for that key.

    Protecting individual accesses does not make the check-create-publish sequence exclusive. If duplicate creation is unacceptable, define a per-key reservation or another correct initialization protocol.

  21. 21.A cache installs a shared promise as its per-key initialization reservation. Another caller finds that promise before initialization finishes. What should the cache contract distinguish?

    Show answer and explanation
    1. Every waiting caller as a second initializer
    2. A reserved in-progress entry from a ready value
    3. Every dictionary entry is already a completed value, even when the stored object explicitly represents unfinished initialization.
    4. A missing dictionary key from a guaranteed successful result

    Answer: A reserved in-progress entry from a ready value

    Reservation prevents some duplicate work but does not establish readiness. Wait for or otherwise handle the promised outcome, including failure and cancellation, instead of treating presence as successful initialization.

  22. 22.Initializer A fails after its cache entry has been replaced by initializer B. A's cleanup deletes the key unconditionally, removing B's valid reservation. What precondition is missing?

    Show answer and explanation
    1. The same key spelling alone, treating the replacement entry as though it still belongs to the failed initializer
    2. The cache currently contains any value for that key.
    3. A performed at least one failed operation.
    4. The entry still belongs to A's initialization attempt.

    Answer: The entry still belongs to A's initialization attempt.

    Delayed cleanup must not remove a newer owner's state. Compare the entry or generation actually owned by the failed attempt before conditionally removing it.

  23. 23.Three callers await one shared initialization. One caller cancels its own wait, and the implementation cancels the shared work for everyone. The API promises independent waiter cancellation. What scope was confused?

    Show answer and explanation
    1. Only whether a value is eventually stored under the key
    2. Only the cancelled caller's wait, treating it as authority to stop work still required by the other two independent waiters
    3. The successful result's representation
    4. One waiter's lifetime and the shared operation's lifetime

    Answer: One waiter's lifetime and the shared operation's lifetime

    Independent cancellation requires a policy for shared work ownership. Abandoning one wait must not silently revoke the still-needed operation unless the stated sharing contract permits that behavior.

  24. 24.A per-key lock registry evicts a lock entry while a thread still holds it. Another caller creates a different lock for the same key and enters. What safety property can fail?

    Show answer and explanation
    1. The original lock object disappeared from every user as soon as its dictionary entry was evicted, even while an existing holder still owns it.
    2. The ability to remove a dictionary entry
    3. Mutual exclusion for that key across entry lifetimes
    4. The key's equality with itself

    Answer: Mutual exclusion for that key across entry lifetimes

    Lock identity and lifetime are part of the synchronization protocol. Removing a registry reference does not make existing holders disappear; replacement can split callers between different locks for one protected resource.

  25. 25.A lock-free algorithm is defined here as guaranteeing that some operation completes despite contention, assuming the required execution steps continue. Does that alone guarantee every particular caller finishes?

    Show answer and explanation
    1. Yes; each caller must complete in FIFO order.
    2. Yes; every caller has a fixed step bound.
    3. No; an individual caller may starve.
    4. No; lock-free means no operation can ever finish.

    Answer: No; an individual caller may starve.

    The supplied property is system-wide progress, not a per-caller completion guarantee. Fairness, starvation freedom, and bounded per-operation progress are separate properties.

  26. 26.An operation is specified to finish within at most 50 of its own execution steps, regardless of interference, provided it receives those steps. What does this bound not guarantee?

    Show answer and explanation
    1. A fixed wall-clock completion time under arbitrary scheduling
    2. A distinction between execution steps and elapsed time
    3. A fixed bound on the operation's own scheduled steps automatically supplies a fixed elapsed-time bound even when the thread receives no CPU.
    4. Completion after the required number of scheduled steps

    Answer: A fixed wall-clock completion time under arbitrary scheduling

    A step bound does not make an unscheduled thread run. Wall-clock guarantees need suitable scheduling and timing assumptions in addition to an algorithmic step bound.

  27. 27.Two workers repeatedly try to acquire two locks. On conflict they release both and retry in the same synchronized pattern forever. What failure is illustrated if neither completes useful work?

    Show answer and explanation
    1. Successful completion
    2. Livelock
    3. A guarantee of fair scheduling
    4. A permanent hold of both locks by one worker

    Answer: Livelock

    The workers take steps and react, yet make no useful progress. Distinguish this from being blocked without steps, and address the retry coordination or progress policy rather than equate activity with completion.

  28. 28.A mutex contract promises mutual exclusion but explicitly gives no FIFO or fairness guarantee. One contender repeatedly loses acquisition. What conclusion is justified?

    Show answer and explanation
    1. The mutex contract has necessarily been violated.
    2. Mutual exclusion alone does not exclude starvation.
    3. Every release transfers ownership to the oldest waiter.
    4. The contender must acquire next because it waited longest.

    Answer: Mutual exclusion alone does not exclude starvation.

    Safety and fairness are distinct. Do not infer FIFO or starvation freedom from an exclusion-only contract; choose and verify a progress policy appropriate to the use case.

  29. 29.A spin loop waits for a flag, but its thread monopolizes the only executor capable of running the task that sets the flag. What progress dependency is broken?

    Show answer and explanation
    1. The producer obtains an extra executor merely because a consumer is actively polling the flag on the only available one.
    2. The awaited producer cannot obtain the execution resource.
    3. Spinning always creates an additional executor.
    4. Reading a flag necessarily schedules the producer.

    Answer: The awaited producer cannot obtain the execution resource.

    Waiting can prevent progress when it consumes the resource needed by the producer. Use a suitable suspension, scheduling, or execution design rather than assume active polling is harmless.

  30. 30.A coroutine holds an exclusive resource and awaits a child that must acquire that same resource before returning. The parent releases it only after the child returns. What dependency results?

    Show answer and explanation
    1. A requirement that the child has already completed
    2. A cycle between the parent's wait and the child's acquisition
    3. Awaiting automatically transfers the parent's exclusive resource to any child that needs it, regardless of the resource contract.
    4. A proof that asynchronous code cannot deadlock

    Answer: A cycle between the parent's wait and the child's acquisition

    Suspension does not remove resource ownership. The parent waits for the child while retaining what the child needs, so the release point is unreachable under the stated protocol.

  31. 31.A condition-variable model allows wakeups even when the predicate is false, and another consumer may take the resource first. After waking, what must a waiting consumer do under the shared-state lock?

    Show answer and explanation
    1. Treat the notification count as the queue's exact length.
    2. Recheck the predicate and wait again if necessary.
    3. Assume every wake grants ownership of the resource.
    4. Consume one item without checking availability.

    Answer: Recheck the predicate and wait again if necessary.

    A wakeup is not the state predicate or a reservation. Recheck the protected condition under the protocol that coordinates producers and consumers.

  32. 32.A consumer checks an empty queue, releases its lock, then registers to wait. A producer adds work and signals in that gap. No later signal occurs. What transition must the wait protocol coordinate?

    Show answer and explanation
    1. Predicate inspection and entering the wait relative to producer updates
    2. Only the queue-size limit, assuming a larger bound prevents a notification from occurring between an uncoordinated check and wait
    3. A guarantee that every signal is retained forever
    4. Only the maximum number of queue entries

    Answer: Predicate inspection and entering the wait relative to producer updates

    A missed-notification window can leave available work with a sleeping consumer. Use the condition primitive's proper coordinated wait protocol instead of separating the check from registration unsafely.

  33. 33.A notification primitive retains no count of past notifications. An implementation sends ten notifications before any waiter exists and later assumes ten waiters can proceed. What assumption is unsupported?

    Show answer and explanation
    1. That the notifications form a durable counting resource
    2. That a caller can execute notify more than once
    3. That the primitive can notify a currently waiting thread
    4. That work may be represented in separate shared state

    Answer: That the notifications form a durable counting resource

    An edge-like notification is not necessarily a stored permit. Keep the actual predicate or use an appropriate counting mechanism under the primitive's stated contract.

  34. 34.A semaphore initially holds three permits. Two successful acquisitions occur and one of those permits is released once. With no other operations, how many permits are available?

    Show answer and explanation
    1. 3
    2. 2
    3. 1
    4. 4

    Answer: 2

    The count is 3 - 2 + 1 = 2. This uses the supplied successful acquisitions and one release; the semaphore does not infer ownership or invent extra releases.

  35. 35.A task acquires a semaphore permit, then exits through an exception path that never releases it. Repeated failures eventually block all later tasks. What lifecycle must be repaired?

    Show answer and explanation
    1. Only increasing the number of tasks started, without returning permits owned by tasks that exit through exceptions
    2. An unconditional increase in the configured permit count after every failure
    3. A release even when no acquisition succeeded
    4. Exactly-once release of each acquired permit on the relevant exit paths

    Answer: Exactly-once release of each acquired permit on the relevant exit paths

    A permit must have a defined owner and release boundary. Cleanup should cover success, failure, and cancellation as required, while avoiding releases for permits the task never acquired.

  36. 36.A cleanup block always releases a semaphore permit, even when cancellation occurred before acquisition succeeded. What accounting error can follow?

    Show answer and explanation
    1. It can create an unearned available permit.
    2. It proves the cancelled task completed its work.
    3. It necessarily decreases the permit count twice.
    4. It always preserves the original bound.

    Answer: It can create an unearned available permit.

    Release should correspond to an acquisition actually owned by the task. Unconditional release after a failed or cancelled acquire can violate the intended concurrency bound.

  37. 37.A bounded channel transfers a mutable object reference to a worker. Channel capacity limits the number of enqueued entries. What does that bound alone fail to establish?

    Show answer and explanation
    1. A distinction between empty and nonempty channel state
    2. The maximum entry count also proves that every referenced object has a single owner, even if producers retain mutable aliases.
    3. The ability to dequeue an entry
    4. Exclusive ownership or safe mutation of each referenced object

    Answer: Exclusive ownership or safe mutation of each referenced object

    Capacity and ownership are different properties. A bounded queue can still contain aliased mutable objects whose use requires a separate lifetime and synchronization protocol.

  38. 38.A channel contract says close rejects future sends but lets consumers drain buffered values. Two values are buffered when close succeeds. What should a consumer's closed-state handling preserve?

    Show answer and explanation
    1. Closing retroactively rejects previously accepted sends.
    2. Closing proves the buffer was empty.
    3. The two values remain receivable under that contract.
    4. The contract requires every buffered value to be discarded.

    Answer: The two values remain receivable under that contract.

    Closing semantics are part of the API. Under the supplied drain contract, do not equate no-more-sends with no-more-receivable-values.

  39. 39.A buffer slot is advertised as ready before its producer finishes writing the payload. A consumer trusts the ready state and reads immediately. What ordering obligation is missing?

    Show answer and explanation
    1. A ready marker publishes all future payload writes retroactively, even if a consumer reads before the producer finishes those writes.
    2. The producer's reservation automatically publishes a finished payload.
    3. The payload must be ready under the publication protocol before consumption is enabled.
    4. The consumer's read retroactively completes initialization.

    Answer: The payload must be ready under the publication protocol before consumption is enabled.

    Reservation and publication are distinct. Establish the required payload initialization, visibility, and lifetime before a ready marker can authorize a consumer to read it.

  40. 40.A ring-buffer model uses the same head and tail indices for both empty and completely full states, with no additional state or reserved-slot rule. What must its protocol distinguish?

    Show answer and explanation
    1. Only whether both equal indices are odd
    2. Only the current numerical capacity, without any occupancy or phase distinction
    3. Those two states despite equal index values
    4. Only the most recent payload value, regardless of the occupancy protocol

    Answer: Those two states despite equal index values

    Modulo indices alone may not encode the required occupancy distinction. Add a correct phase, count, sequence, or capacity convention and verify its wraparound semantics under the chosen model.

  41. 41.A queue permits null as a real payload but also uses null in each slot as its only indication that the slot is empty. What representation problem must it solve?

    Show answer and explanation
    1. A valid null payload must be distinguishable from empty state.
    2. A null payload necessarily requires two physical queue entries.
    3. A queue cannot store any tagged representation.
    4. A null payload is automatically forbidden by every queue API.

    Answer: A valid null payload must be distinguishable from empty state.

    The state representation must cover the payload domain and occupancy state without ambiguity. Use a suitable tag or protocol rather than reserve a value that the stated payload contract allows.

  42. 42.In a supplied snapshot model, a serialized writer makes version 5 while updating and version 6 when finished. A reader first sees version 4, copies fields, then sees 6. The rule accepts only equal even versions, with no wraparound. What should the reader do?

    Show answer and explanation
    1. Replace the copied fields' version label with 6 and keep them.
    2. Accept because the final version is larger.
    3. Accept because both observed versions are even.
    4. Retry the observation.

    Answer: Retry the observation.

    The version change shows that the copy may overlap an update. Under the supplied acceptance rule, equal even observations are required; a larger final version does not validate the earlier field copy.

  43. 43.An optimistic snapshot reader retries whenever a concurrent writer changes the version. Writers can continue changing it indefinitely. What completion claim requires more assumptions?

    Show answer and explanation
    1. That this particular reader eventually obtains an accepted snapshot
    2. That a version can be compared before and after copying
    3. That the writer can publish a new version
    4. That the reader can reject a detected overlapping update

    Answer: That this particular reader eventually obtains an accepted snapshot

    Retry-based safety does not alone establish reader progress under continuous interference. Specify the progress and scheduling assumptions or a fallback appropriate to the required completion guarantee.

  44. 44.A snapshot protocol rejects odd versions. Its sole writer crashes after marking the version odd, and no recovery mechanism exists. What liveness gap remains?

    Show answer and explanation
    1. Every reader can repair the payload merely by changing its version label.
    2. The writer's crash automatically completes its final version update.
    3. Readers may retry forever without a valid publication or recovery path.
    4. An odd version proves the partially updated payload is safe to accept.

    Answer: Readers may retry forever without a valid publication or recovery path.

    The model can preserve rejection of incomplete state while losing progress. Recovery must establish a valid state, not merely relabel an unknown partial update as complete.

  45. 45.Readers hold references to an old immutable configuration after a new one is published. The updater immediately destroys the old configuration. What must reclamation establish?

    Show answer and explanation
    1. At least one reader has observed the new configuration.
    2. No permitted reader still depends on the old object's lifetime.
    3. Only publication of the new current pointer, treating it as proof that every reader released all earlier references
    4. The old pointer is no longer the current pointer.

    Answer: No permitted reader still depends on the old object's lifetime.

    Replacing the current reference does not end every prior reader's use. Reclamation needs a valid ownership or quiescence protocol for readers that may retain the old object.

  46. 46.A task system defines cancellation as a request observed at cooperative checkpoints. A cancellation request is accepted while a task is executing between checkpoints. What is not yet proven?

    Show answer and explanation
    1. That the task has stopped and released its resources
    2. That a cancellation request was recorded
    3. That the task can reach a later checkpoint
    4. That the caller has asked to stop the task

    Answer: That the task has stopped and released its resources

    Accepted cancellation and completed termination are distinct states. Follow the task's actual completion and cleanup evidence rather than treat the request acknowledgment as proof of quiescence.

  47. 47.A parent starts child tasks that use a shared file handle. It returns and closes the handle while children may still run. What scope should ownership enforce?

    Show answer and explanation
    1. Child task creation necessarily copies the file's entire contents.
    2. Closing the parent's reference makes all child operations successful.
    3. Returning from the parent proves all children finished, even when the task contract permits those children to keep using the shared handle.
    4. The handle remains valid for every permitted child use.

    Answer: The handle remains valid for every permitted child use.

    The resource lifetime must cover the work that uses it. Join, cancel and observe completion, or transfer suitable ownership according to the task and handle contracts.

  48. 48.A detached task can fail after its parent reports success. No component retains its handle or observes its result. What responsibility is undefined?

    Show answer and explanation
    1. Whether a task can have an exception
    2. Who owns completion and failure handling for that task
    3. Whether code can run after the parent returns
    4. Whether the parent once created a task

    Answer: Who owns completion and failure handling for that task

    Background work needs explicit lifetime, result, and failure ownership. Detaching a handle does not establish that failures are handled or that the intended operation succeeded.

  49. 49.A cooperative task appends an entry to a shared list, then observes cancellation and raises a cancellation result. What cannot the caller infer from that result alone?

    Show answer and explanation
    1. That the cancellation result can be reported
    2. That the task observed cancellation
    3. That no shared-state effect occurred
    4. That the task may have executed before observing cancellation

    Answer: That no shared-state effect occurred

    Cancellation is not automatic rollback of earlier effects. Define the operation's state and recovery or compensation behavior instead of interpreting a cancelled outcome as proof that nothing happened.

  50. 50.Completion and cancellation race to finalize one promise. Its contract allows exactly one transition from pending to a terminal state. What must coordinate the race?

    Show answer and explanation
    1. Separate unchecked writes to completed and cancelled flags, treating either flag alone as permission for independent terminal side effects
    2. A requirement that wall clocks choose the winner afterward
    3. The wall-clock timestamp of each callback without a coordinated terminal transition
    4. One atomic or otherwise correctly synchronized terminal transition

    Answer: One atomic or otherwise correctly synchronized terminal transition

    The terminal-state decision must have a consistent winner under the promise's contract. Separate unchecked flags can represent conflicting final outcomes or permit duplicate completion effects.

  51. 51.A first-result combinator selects one winning task and returns. Losing tasks can still write into a shared result buffer. What must the combinator's lifecycle account for?

    Show answer and explanation
    1. A guarantee that selecting a winner terminates every loser immediately
    2. A guarantee that an ignored task cannot perform side effects
    3. Only the winning result, treating selection as proof that every losing task stopped mutating the shared buffer
    4. Losing tasks' authority and lifetime after selection

    Answer: Losing tasks' authority and lifetime after selection

    Result selection is not the same as stopping other work. Define cancellation, completion observation, buffer ownership, and late-result handling so losers cannot corrupt a finalized result.

  52. 52.A timeout returns to the caller, but the worker retains a borrowed pointer to the caller's soon-destroyed temporary storage. What lifetime is unsafe?

    Show answer and explanation
    1. Returning a timeout transfers ownership of all caller storage automatically.
    2. The worker may outlive the storage it can still access.
    3. A timeout return proves that the still-running worker has no permission or ability to access any borrowed storage.
    4. A nonnull borrowed pointer proves its target still exists.

    Answer: The worker may outlive the storage it can still access.

    A caller's wait ending does not necessarily end the work. Preserve storage until legitimate users are done, transfer valid ownership, or ensure termination according to the actual protocol.

  53. 53.A promise invokes a user callback before recording its terminal state. The callback reenters the promise and sees pending, allowing a second completion. What ordering should its design address?

    Show answer and explanation
    1. Use the callback's elapsed time to decide which completion counted.
    2. Commit the terminal decision before exposing a reentrant completion callback.
    3. Assume callback invocation is a non-reentrant boundary even though the API permits that callback to invoke completion again.
    4. Treat callback entry as equivalent to a durable terminal-state transition.

    Answer: Commit the terminal decision before exposing a reentrant completion callback.

    Reentrancy can observe state during an operation. Establish a consistent terminal decision and appropriate callback policy before invoking external code that can reenter the object.

  54. 54.A callback's exception prevents code after the callback from releasing an owned resource. What must the resource protocol cover?

    Show answer and explanation
    1. Only callbacks that return normally, treating an exception thrown by user code as unable to bypass subsequent manual release
    2. A second acquisition to balance the missing release
    3. A rule that callback exceptions cannot affect surrounding control flow
    4. Release on the relevant exceptional callback path

    Answer: Release on the relevant exceptional callback path

    Calling external code can introduce an exceptional exit. Use cleanup appropriate to the language and resource contract so ownership is not abandoned when the callback fails.

  55. 55.An unsubscribe operation prevents future callback enqueueing but explicitly does not remove callbacks already queued. A client destroys callback state immediately after unsubscribe returns. What is still required?

    Show answer and explanation
    1. A safe policy for queued or in-flight callbacks and their state lifetime
    2. A guarantee that queue order automatically retains destroyed state
    3. Unsubscribe necessarily removes every queued callback, despite the contract only preventing future enqueueing.
    4. A replacement subscription using the same key without accounting for older queued callbacks

    Answer: A safe policy for queued or in-flight callbacks and their state lifetime

    Use the actual unsubscribe guarantee. Queued work may still need a valid target, generation check, safe indirection, or verified quiescence before its state can be destroyed.

  56. 56.A timer cancellation removes only timers that have not started. The handler may already be running and can publish a result after a newer timer takes ownership. What should result publication validate?

    Show answer and explanation
    1. Only whether the new timer's interval is longer
    2. The still-current ownership or generation for the intended result
    3. Only whether cancellation was requested
    4. Only whether both timers use the same callback function

    Answer: The still-current ownership or generation for the intended result

    Cancellation of pending scheduling does not necessarily revoke an in-flight handler. A late publication needs the appropriate ownership check or synchronization at its actual effect boundary.

  57. 57.In a supplied closure model, callbacks capture one mutable loop variable by reference. After the loop, that variable is 4. All callbacks run afterward and read it then. What value do they read?

    Show answer and explanation
    1. 4
    2. 0 for every callback
    3. An independently chosen random value
    4. Each callback's earlier loop value automatically

    Answer: 4

    The model says each callback reads the same referenced variable after the loop. Capture a suitable per-iteration value or state when callbacks require distinct earlier values.

  58. 58.A function changes an object to a provisional state, then calls user code that can inspect it reentrantly. Its invariant was intended to hold whenever user code runs. What boundary must it protect?

    Show answer and explanation
    1. Only the invariant at final return, even though permitted user code can observe the provisional state during the earlier callback
    2. Only the callback's successful return value
    3. The invariant before making the external call
    4. A guarantee that every callback waits until all enclosing functions return

    Answer: The invariant before making the external call

    External code can observe or reenter during the call. Restore or represent valid state before that boundary, or explicitly design a protocol that prevents invalid observations.

  59. 59.An operation changes one field, then fails before changing a second required field. Catching the exception reports failure but leaves the shared object in a broken invariant. What guarantee is not supplied by catch alone?

    Show answer and explanation
    1. The ability to report that an exception occurred
    2. Restoration of a valid shared state
    3. The ability to enter an error-handling branch
    4. The existence of a partially executed operation

    Answer: Restoration of a valid shared state

    Handling an exception does not automatically undo earlier mutation. Define rollback, a valid partial state, or another recovery guarantee and protect observers throughout the transition.

  60. 60.A cleanup action can itself fail while an earlier operation is already failing. The API requires reporting the original failure and recording cleanup failure separately. What must error handling preserve?

    Show answer and explanation
    1. The specified primary failure and secondary cleanup evidence
    2. A requirement to discard both failures
    3. Only a generic success response from cleanup
    4. Only whichever failure happened last

    Answer: The specified primary failure and secondary cleanup evidence

    Failure composition is part of the contract. Preserve the intended primary outcome and required secondary diagnostics rather than accidentally replace or hide the original problem.

  61. 61.A critical cleanup is protected from ordinary task cancellation under a supplied policy, but it can wait forever on a dependency. What separate requirement remains unresolved?

    Show answer and explanation
    1. Bounded progress or a defined handling policy for stuck cleanup
    2. A guarantee that entering cleanup proves it completed
    3. A guarantee that cancellation protection makes every dependency responsive
    4. The existence of any resource requiring cleanup

    Answer: Bounded progress or a defined handling policy for stuck cleanup

    Preventing cancellation does not make cleanup finish. Define progress assumptions, time bounds, escalation, or recovery appropriate to the resource and operation requirements.

  62. 62.A task acquires resource A, then acquisition of B fails. The failure path releases neither because the full operation never started. What ownership obligation already exists?

    Show answer and explanation
    1. Release or validly transfer the successfully acquired A.
    2. Acquire A again to cancel its earlier acquisition.
    3. Release B even though acquisition failed, while retaining A because the full operation never reached its success path.
    4. Assume failure of B automatically relinquished A.

    Answer: Release or validly transfer the successfully acquired A.

    Partial acquisition still creates ownership. Track which resources were actually obtained and handle each relevant exit without leaking or inventing ownership.

  63. 63.A resource contract requires child handle B to be closed while parent A remains valid. Both were acquired successfully. Which cleanup sequence respects that dependency?

    Show answer and explanation
    1. Close B, then A.
    2. Drop A and assume B closes before it is used.
    3. Close both in any order because acquisition succeeded.
    4. Close A, then B.

    Answer: Close B, then A.

    The dependency gives a specific lifetime order. Cleanup must preserve A until B's required close operation finishes; unrelated general assumptions about destruction order are insufficient.

  64. 64.A callback contract permits borrowing a buffer only until that callback returns. It starts a task that reads the borrowed buffer later without copying or retaining an authorized owner. What contract is violated?

    Show answer and explanation
    1. The ability to read any buffer during the callback
    2. The borrowed buffer's permitted lifetime
    3. The existence of a buffer length field
    4. The task's ability to be scheduled later

    Answer: The borrowed buffer's permitted lifetime

    A deferred task can outlive a borrow scoped to the callback. Obtain an appropriate owned representation or otherwise establish a valid lifetime before extending use beyond the stated boundary.

  65. 65.A pool reuses slot 7 for a new lease after the old lease ends. A delayed duplicate return from the old holder marks slot 7 free again. What identity must the return validate?

    Show answer and explanation
    1. Only the old holder's original successful acquisition
    2. Only the slot's current existence
    3. The specific lease incarnation, not just the slot number
    4. Only a valid slot number, treating an old return as authority to release whichever newer lease currently occupies that slot

    Answer: The specific lease incarnation, not just the slot number

    A reused slot is not the same ownership instance. Reject stale or duplicate returns according to the lease protocol so an old holder cannot release capacity owned by a new holder.

  66. 66.A lock table intentionally maps several independent keys to one shared mutex. All accesses to each key use that mapping consistently. What can a hash collision do without itself breaking exclusion?

    Show answer and explanation
    1. Prove that the mutex is no longer indivisible
    2. Automatically merge the keys' stored values
    3. Necessarily allow two protected accesses to the same key simultaneously
    4. Cause unrelated keys to serialize unnecessarily

    Answer: Cause unrelated keys to serialize unnecessarily

    Sharing a mutex can conservatively serialize extra work. Distinguish that performance consequence from losing protection or incorrectly treating different resource identities as the same data item.

  67. 67.A result cache stores only a key's hash and treats equal hashes as proof of equal keys. Two distinct inputs collide and require different results. What correctness check is missing?

    Show answer and explanation
    1. A requirement that all hash values be larger than the input
    2. Only the chronological order of lookups
    3. The required identity or equality check beyond the hash alone
    4. Only a mutex around hash calculation, treating synchronized equality of hash values as proof that the original input keys are equal

    Answer: The required identity or equality check beyond the hash alone

    A hash can be useful for indexing without proving identity. Preserve the equality and scope required by the cached result rather than conflate different inputs that share a hash.

  68. 68.A test intends to exercise a two-lock order conflict. It sleeps briefly and assumes both threads hold their first lock before either proceeds. What should control the intended schedule instead?

    Show answer and explanation
    1. A guarantee that thread start order fixes every later interleaving
    2. Explicit synchronization establishing those required state boundaries
    3. A larger arbitrary sleep as proof that both locks are held
    4. The order in which test threads were submitted, without observing whether they hold the intended locks

    Answer: Explicit synchronization establishing those required state boundaries

    Elapsed delay does not establish the intended program state. Use appropriate deterministic coordination and observations so the test actually exercises the lock dependency it claims to cover.

  69. 69.A register starts at 0 and has no other writer. A write of 1 completes before a read is invoked. The contract requires linearizability. Can that read return 0?

    Show answer and explanation
    1. No; the completed write must precede that later read.
    2. Yes; a stale value is always permitted for any register.
    3. Yes; real-time order is irrelevant under the supplied contract.
    4. No; linearizability forbids every read operation.

    Answer: No; the completed write must precede that later read.

    The completed-before-invoked relation must be preserved in a linearizable history. With no later write, that read must observe the value 1 under the stated register contract.

  70. 70.A register starts at 0. A write of 1 overlaps a read, and no other operation occurs. Under a linearizable register model, which read results can fit a valid order?

    Show answer and explanation
    1. Only 1 because a write was invoked
    2. 0 or 1, depending on the linearization order
    3. Only 0 because the operations overlap
    4. Any integer, because overlap removes the register's semantics

    Answer: 0 or 1, depending on the linearization order

    Overlapping operations may be ordered either way if the resulting history respects the register semantics and all required precedence. The overlap does not authorize arbitrary values.

  71. 71.A cooperative single-thread scheduler switches tasks only at defined suspension points. One task performs a long CPU loop with no suspension. What can happen to other ready tasks during that loop?

    Show answer and explanation
    1. Declaring them ready grants them independent CPU cores.
    2. Their pending state proves they already completed.
    3. They necessarily execute simultaneously on the same thread.
    4. They cannot run on that executor until it yields or finishes.

    Answer: They cannot run on that executor until it yields or finishes.

    Readiness is not execution. Under the supplied scheduler, a task that does not relinquish the executor can delay all other work assigned to it.

  72. 72.In a supplied runtime, calling an asynchronous function creates an unscheduled coroutine object; the body runs only when awaited or scheduled. A caller creates the object and discards it. What execution is established?

    Show answer and explanation
    1. The runtime must have run it in a background thread.
    2. The body has not been run by that call alone.
    3. The body necessarily completed before the object was returned.
    4. Discarding the object schedules its first step.

    Answer: The body has not been run by that call alone.

    Asynchronous call semantics vary. Under the explicitly supplied model, construction does not execute the body; use the runtime's actual await or scheduling mechanism to request execution.

  73. 73.A task factory is defined to execute a new task immediately until its first suspension. A parent creates that task before initializing state the child reads. What assumption is unsafe?

    Show answer and explanation
    1. Task creation itself guarantees the parent completes all following initialization before the child can run, even under the supplied eager factory.
    2. That the parent can initialize shared state eventually
    3. That child execution always starts after the parent's following initialization
    4. That the child can suspend later

    Answer: That child execution always starts after the parent's following initialization

    An eager-start contract can expose state during task creation. Establish the child's prerequisites before that observable execution boundary rather than assume deferred scheduling.

  74. 74.A completion stream returns task results in completion order, not submission order. The caller pairs the first result with the first submitted resource unconditionally. What correlation is needed?

    Show answer and explanation
    1. Only the longest task's expected duration
    2. Only the result's arrival position
    3. The result's actual task or resource identity
    4. Only the original submission index without a returned identity

    Answer: The result's actual task or resource identity

    When order is not guaranteed, positional pairing can update the wrong resource. Preserve the identity required by the stream contract rather than substitute submission order for completion identity.

  75. 75.A task-combination API returns the first child error but explicitly leaves other children running. The caller treats the return as proof it can destroy all shared child state. What lifecycle fact is missing?

    Show answer and explanation
    1. The ability of a child to fail
    2. The occurrence of one reported error
    3. The existence of a parent return value
    4. Completion or valid ownership of the still-running children

    Answer: Completion or valid ownership of the still-running children

    Error propagation and termination of all work are different guarantees. Observe or transfer the remaining work's lifetime before reclaiming state it may still use.

  76. 76.A cooperative worker catches its cancellation signal and continues processing indefinitely. The system does not forcibly terminate it. What cannot the caller infer from having requested cancellation?

    Show answer and explanation
    1. That a request to stop was made
    2. That the worker may have observed the request
    3. That continued execution requires a defined policy
    4. That the worker has terminated

    Answer: That the worker has terminated

    The stated runtime permits the worker to continue after handling the signal. Use actual completion evidence and an appropriate policy for cancellation handling rather than equate a request with termination.

  77. 77.A scheduler can resume one logical task on a different thread after suspension. The task assumes a thread-local variable automatically follows its logical context. What mapping must be explicit?

    Show answer and explanation
    1. Task context versus the executing thread's local state
    2. The current thread ID as a stable logical operation ID
    3. A guarantee that suspension preserves physical thread assignment
    4. Every thread-local value automatically belongs to the migrating task, even when a different thread executes its continuation.

    Answer: Task context versus the executing thread's local state

    Thread-local storage belongs to an execution thread under the supplied model, not automatically to a migrating task. Propagate or scope logical context through an appropriate runtime contract.

  78. 78.A thread-pool worker sets request-specific context, then exits through an error path without clearing it. The next request on that thread inherits the old context. What boundary needs cleanup?

    Show answer and explanation
    1. Only the pool thread's eventual shutdown, treating every intervening request as permitted to inherit the prior request's context
    2. A rule that thread reuse creates a fresh thread-local store
    3. The context's per-request lifetime on all relevant exits
    4. Only the next successful request's final response

    Answer: The context's per-request lifetime on all relevant exits

    Worker reuse can outlive request state. Establish and restore context reliably, including failure and cancellation, so the next logical request cannot inherit a prior request's state.

  79. 79.A UI contract permits model mutation only on its owner executor. A background task completes and directly mutates that model from another executor. What must completion handling respect?

    Show answer and explanation
    1. Only whether the background computation succeeded
    2. The model's executor-affinity and lifetime contract
    3. A guarantee that any callback automatically runs on the owner executor
    4. Only whether the model reference is nonnull

    Answer: The model's executor-affinity and lifetime contract

    Successful work does not authorize mutation from an arbitrary executor or after the target's lifetime. Dispatch and validate the completion according to the model's actual ownership rules.

  80. 80.A service begins shutdown by closing resources its workers need, then asks those workers to drain accepted work. What ordering requirement should the shutdown protocol resolve?

    Show answer and explanation
    1. Closing dependencies is proof that all accepted worker operations have drained successfully, regardless of whether those workers still run.
    2. Draining can always finish after every dependency is destroyed.
    3. Stop or account for work before invalidating resources it can still use.
    4. Shutdown automatically rolls back all prior accepted work.

    Answer: Stop or account for work before invalidating resources it can still use.

    Shutdown is a state transition with resource and work dependencies. Define admission closure, draining or cancellation, completion observation, and resource teardown in an order consistent with the promised outcomes.

  81. 81.Consumers wait for either available work or a shutdown predicate. Shutdown changes the predicate under the lock but never wakes sleeping consumers, and no more producers run. What progress step is missing?

    Show answer and explanation
    1. Notify or otherwise resume waiters so they can observe shutdown.
    2. Changing a field necessarily wakes every blocked thread.
    3. Consumers must infer shutdown without executing.
    4. The queue must contain one real job for each shutdown request.

    Answer: Notify or otherwise resume waiters so they can observe shutdown.

    A true predicate does not execute a sleeping task by itself. The wait protocol must provide the relevant wakeup or other progress mechanism and recheck the predicate correctly.

  82. 82.An initialization API explicitly caches its first failure and permits retries only after an authorized reset. A caller repeatedly invokes get() expecting a fresh initializer each time. What should the caller follow?

    Show answer and explanation
    1. A rule that any failure is silently converted to a default success
    2. An assumption that every repeated call starts a new attempt
    3. The specified failure and reset lifecycle
    4. An assumption that cached state disappears when a caller stops waiting

    Answer: The specified failure and reset lifecycle

    Once or lazy initialization has an outcome policy, not just a successful-value path. Handle its defined failed state and reset transition rather than invent a retry guarantee.

  83. 83.An ownership API consumes a unique resource token and prohibits later use through the original token. A caller stores an alias and continues using it after transfer. What property must the ownership model enforce?

    Show answer and explanation
    1. Only changing the source variable, assuming all retained aliases become invalid or disappear automatically under any ownership API
    2. Only successful return from the transfer method
    3. The validity and permitted use of every surviving alias
    4. A guarantee that changing one variable destroys all aliases automatically

    Answer: The validity and permitted use of every surviving alias

    Ownership transfer is meaningful only when aliasing and subsequent use obey its rules. A syntactic move or assignment does not by itself establish that every other access path is valid or forbidden as intended.

  84. 84.A failure guarantee promises that an unsuccessful operation leaves the original state unchanged. The operation fails after replacing a field with a different valid value. Does this meet that guarantee?

    Show answer and explanation
    1. Yes; reporting failure makes the state change irrelevant to this guarantee.
    2. Yes; any valid resulting state meets an unchanged-state guarantee.
    3. No; valid state can still differ from the original.
    4. Yes; only leaked resources can violate an unchanged-state guarantee.

    Answer: No; valid state can still differ from the original.

    Validity is weaker than unchanged state. Match implementation and tests to the stated failure guarantee rather than treating any valid resulting value as equivalent to rollback.

  85. 85.A function manually unlocks its mutex only at its normal return. An exception can leave earlier. What must synchronization cleanup cover?

    Show answer and explanation
    1. Every exit that still owns the mutex
    2. A new lock acquisition to compensate for each exception
    3. Only normal returns, treating an exception path as if it could not leave the function while retaining the acquired mutex
    4. An unlock even before lock acquisition succeeds

    Answer: Every exit that still owns the mutex

    Lock ownership needs a reliable release path consistent with the language and primitive. Track successful acquisition and handle exceptional exits without leaking ownership or unlocking something not owned.

  86. 86.A getter is exposed as read-only but lazily updates an internal cache shared across callers. No synchronization or immutable publication protects that cache. What claim is not established by the method's label?

    Show answer and explanation
    1. Concurrent safety of the hidden mutation
    2. That callers can invoke the method
    3. That the API can return a value
    4. That a cache can hold computed data

    Answer: Concurrent safety of the hidden mutation

    An API label does not define all internal effects. Shared lazy mutation still needs a suitable concurrency and lifetime protocol, even if the externally visible operation is described as a read.

  87. 87.A collection documents individually safe get and put operations but makes no concurrent-iteration guarantee. A caller iterates while another thread modifies it. What must the caller verify?

    Show answer and explanation
    1. A requirement to treat every modification as a new collection instance
    2. The separate iterator and mutation contract
    3. A guarantee that individual operation safety freezes the collection
    4. Individually safe get and put calls prove arbitrary concurrent iteration is safe, even though that separate guarantee is explicitly absent.

    Answer: The separate iterator and mutation contract

    Operation-level guarantees have scope. Iteration can span multiple observations and lifetimes, so follow its actual consistency and synchronization contract rather than infer it from unrelated methods.

  88. 88.An operation protects an invariant with a mutex and restores it before releasing. All observers participate in that lock protocol, and no callback exposes intermediate state. What can be permitted inside the critical section?

    Show answer and explanation
    1. A claim that release can happen before restoring the invariant
    2. An observer bypassing the stated lock protocol
    3. An invalid state visible after the mutex is released
    4. A temporary internal state that no allowed observer can see

    Answer: A temporary internal state that no allowed observer can see

    The relevant invariant must hold at its specified observable boundaries. A privately held transition can have internal intermediate state if the protocol truly prevents its exposure and handles failure correctly.

  89. 89.Two threads acquire reentrant locks L and M in opposite orders. Each holds one and waits for the other, which the other thread owns. What does reentrancy fail to remove?

    Show answer and explanation
    1. The cross-thread lock-order cycle
    2. The existence of two different lock objects
    3. The ability to define an acquisition order
    4. The ability of a holder to reacquire its own lock under its contract

    Answer: The cross-thread lock-order cycle

    Reentrancy can address reacquisition by the same thread without resolving cycles between different owners. Keep the lock-order and dependency reasoning separate from the self-acquisition property.

  90. 90.A model's publication edge makes earlier payload writes visible. A writer publishes ready, then initializes the payload afterward. A reader follows the ready marker's acquire rule. What initialization obligation is missing?

    Show answer and explanation
    1. The required payload writes precede publication.
    2. The writer can store a ready value.
    3. An acquire exists on the reader path.
    4. The payload has an allocated representation.

    Answer: The required payload writes precede publication.

    A visibility rule for earlier writes does not publish future initialization retroactively. Establish the payload and its valid lifetime before the publication that authorizes reading it.

  91. 91.A supplied machine model places two independently protected counters on one coherence unit, so writes to either can trigger ownership traffic for that unit. What can follow without a logical data race?

    Show answer and explanation
    1. Proof that their protected increments are not indivisible
    2. A requirement that the counters have equal values
    3. Automatic loss of one counter's updates
    4. Performance interference through the shared coherence unit

    Answer: Performance interference through the shared coherence unit

    Physical sharing can create communication overhead even when logical state is independently protected. Distinguish that performance effect from the correctness and synchronization claims for the counters.

  92. 92.An atomic-operation contract promises indivisible updates but gives no nonblocking progress guarantee. What cannot be inferred from atomicity alone?

    Show answer and explanation
    1. That each promised update is indivisible
    2. That an operation has an interface contract
    3. That users may need separate lifetime reasoning
    4. That its implementation is lock-free

    Answer: That its implementation is lock-free

    Atomicity describes an effect's indivisibility under its contract. The implementation's blocking behavior and progress guarantees require separate evidence; an atomic label does not supply them automatically.

  93. 93.A concurrent test checks one forced interleaving and finds no invariant violation. What scope does that result directly support?

    Show answer and explanation
    1. The execution and assertions actually exercised
    2. Every possible interleaving and failure condition
    3. A guarantee that a different memory model has identical behavior
    4. A universal proof of starvation freedom

    Answer: The execution and assertions actually exercised

    A passing schedule can be useful evidence without exhaustive proof. State the tested model, schedule, observations, and assertions, and gather further evidence for stronger claims.

  94. 94.A concurrency harness randomizes timing, but every run happens to execute one worker fully before the other. The suspected bug needs overlap. What evidence is missing?

    Show answer and explanation
    1. The number of randomized runs alone, without observing or controlling the required overlapping state
    2. A guarantee that randomization always covers every interleaving
    3. The fact that the harness can print a pass result
    4. That the relevant overlapping schedule was exercised

    Answer: That the relevant overlapping schedule was exercised

    Random inputs or delays do not establish schedule coverage. Observe or control the relevant state boundaries so the test reaches the suspected overlap and checks its consequences.

  95. 95.A snapshot API returns references into a locked object, then releases the lock before the caller uses those references. Other threads may mutate or destroy the referenced data. What must the snapshot guarantee address?

    Show answer and explanation
    1. A guarantee that release permanently freezes all returned objects
    2. Only the lookup-time mutex, treating it as permanent protection for references used after the lock is released and mutation resumes
    3. The returned representation's consistency and lifetime after return
    4. Only whether the referenced addresses are nonnull

    Answer: The returned representation's consistency and lifetime after return

    Protection during lookup does not necessarily protect later use. Return suitable owned or immutable state, retain protection, or define another valid lifetime and observation contract.

  96. 96.A reentrant mutex permits a callback on the same thread to reacquire it. The callback runs while an invariant is temporarily broken inside the outer operation. What exposure remains possible?

    Show answer and explanation
    1. The callback can observe the invalid intermediate state.
    2. A successful reacquire proves every field is ready.
    3. A successful reentrant acquire itself repairs any temporarily broken invariant before the callback reads the fields.
    4. Holding the mutex prevents all same-thread reentry.

    Answer: The callback can observe the invalid intermediate state.

    Reentrancy can avoid self-blocking while allowing observation during a transition. Restore a valid observable state or design an explicit reentrancy policy; the lock property alone does not establish invariants.

  97. 97.A test times out while a worker makes no visible progress. No dependency or scheduling evidence was collected. What diagnosis is not proven by the timeout alone?

    Show answer and explanation
    1. That the test's chosen deadline elapsed
    2. That further progress investigation is needed
    3. That expected completion was not observed in time
    4. A deadlock rather than another source of delay

    Answer: A deadlock rather than another source of delay

    A timeout reports an observation limit, not a unique cause. Distinguish a dependency cycle, starvation, slow work, blocked I/O, or a faulty observer using appropriate evidence.

  98. 98.A completion log is emitted after an operation's effect. Logging can be delayed independently across threads. A checker treats log arrival order as the effect's exact order. What must it establish?

    Show answer and explanation
    1. Only that all records use one text format
    2. Only wall-clock labels on delayed messages, treating logging transport arrival as the exact global effect order
    3. A valid mapping from observations to the required operation history
    4. A guarantee that output transport preserves every thread's effect order globally

    Answer: A valid mapping from observations to the required operation history

    Observation and effect can occur at different boundaries. A correctness checker needs the invocation, response, identity, and ordering evidence appropriate to the model rather than equating transport arrival with linearization.

  99. 99.A shutdown flag is atomic, but a worker reads it once and stores the value in a local variable used forever. Shutdown later changes the flag. What observation obligation is missing?

    Show answer and explanation
    1. A local copy automatically changes whenever another thread updates the original atomic object, even when the worker never reads it again.
    2. Atomicity forces a new read on every loop iteration regardless of code.
    3. The worker must observe the relevant later state under the protocol.
    4. A true flag physically terminates any worker holding an old value.

    Answer: The worker must observe the relevant later state under the protocol.

    An atomic object does not update independent local copies. The worker's control flow and memory protocol must include the observations and progress needed for the shutdown contract.

  100. 100.An operation times out while its worker still holds a mutex and may resume mutating protected state. A recovery path simply declares that mutex unlocked for another worker. What safety issue must be resolved?

    Show answer and explanation
    1. Concurrent authority over state the original owner may still modify
    2. Only a changed lock-state label without a state-recovery or stale-owner protocol
    3. Only the fact that a waiter timed out, treating it as proof that the original owner can never resume protected mutation
    4. A guarantee that every timeout proves the owner is permanently stopped

    Answer: Concurrent authority over state the original owner may still modify

    Removing a wait does not establish safe ownership transfer. A valid recovery protocol must account for the original owner's lifetime, state consistency, and any enforcement that prevents stale effects.

  101. 101.A review calls a structure concurrent-safe because its fields use atomics. What contract must still be assessed for the structure's intended use?

    Show answer and explanation
    1. A guarantee that any combination of atomic fields satisfies every invariant
    2. The use of an atomic keyword alone, treating it as proof of every compound invariant, lifetime, observation, and progress property
    3. Compound state, visibility, lifetime, ownership, and required progress
    4. Only the number of threads that compiled successfully

    Answer: Compound state, visibility, lifetime, ownership, and required progress

    Primitive guarantees are building blocks. A structure's safety and progress claims require reasoning about complete operations, observations, object lifetimes, dependencies, and the actual execution model.