Message Passing and Asynchronous Work · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.
En anglais

Do not share, just send word

Computing · Computer Systems · ages 21-22
Name ______________________   Date ____________
  1. A bounded queue is full and uses blocking sends. What happens to a producer trying to send its next message?

    • It waits until the queue has space to accept its message.
    • It grows the queue beyond its capacity to store its message.
    • It removes the oldest queued message before storing its own.
  2. In the single-owner counter design, who may directly read and update the counter?

    • Any sender that has already enqueued an update
    • Only the worker that owns the counter
    • Any sender while the owner's queue is empty
  3. An asynchronous caller must stop all other work until its reply arrives.

    Circle one:   True   False

  4. An empty queue receives 5 messages each second. Its consumer handles 3 each second. It has enough space and drops nothing. After 3 seconds, how many messages remain queued?

    • 2
    • 4
    • 6
  5. A counter owner starts at 0 and completes add 2, add 3, then add 1. What is the final count?

    • 5
    • 6
    • 7
  6. Which comparison correctly limits the guarantees of the single-owner counter design?

    • It removes sender races on the counter, but queue and blocking risks remain.
    • It removes sender races on the counter and prevents every deadlock elsewhere.
    • It keeps senders writing the counter directly but makes every queue unlimited.
  7. A receiver must handle Save before Notify. It completes one event before taking the next. Independent producers may enqueue either event first. No messages are dropped. Which design guarantees the required order in a FIFO queue?

    • Start the Save producer first, then let both producers enqueue independently.
    • Give each producer a FIFO queue and merge their messages as they arrive.
    • Use one coordinator to enqueue Save, then Notify, into the receiver's queue.
  8. A client sends requests 31 for a count, 32 for status and 33 for a reset. Replies arrive with IDs 32 then 31. Request 33 misses its deadline under a timeout policy. How should the client handle this?

    • Assign the first reply to request 31 and the second to 32; keep waiting for 33 without a timeout.
    • Match each reply by its ID and report the timeout for request 33.
    • Treat reply 31 as success for all three requests and discard the missing reply for request 33.
LightMySky · lightmysky.comW1-mt_twcpO-945r-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Do not share, just send word W1-mt_twcpO-945r-s1

  1. It waits until the queue has space to accept its message. · This queue uses a blocking policy. Waiting for available space applies back pressure to the sender.
  2. Only the worker that owns the counter · The counter's owner alone accesses its state. Other workers communicate with it through messages.
  3. False · An asynchronous caller can continue before completion. It still needs a way to handle a later reply or failure.
  4. 6 · The queue gains 5 - 3 = 2 messages each second. Over 3 seconds, 2 × 3 = 6 messages remain.
  5. 6 · Apply the updates in turn: 0 + 2 = 2, 2 + 3 = 5, and 5 + 1 = 6.
  6. It removes sender races on the counter, but queue and blocking risks remain. · Serial ownership removes direct sender races on this counter. Full queues, ordering errors and deadlocks from blocking messages can still occur.
  7. Use one coordinator to enqueue Save, then Notify, into the receiver's queue. · One coordinator enqueuing Save then Notify fixes the enqueue order. FIFO preserves that order, and the receiver finishes Save before taking Notify.
  8. Match each reply by its ID and report the timeout for request 33. · Reply 32 answers the status request, and reply 31 answers the count request. Request 33 has no reply by its deadline, so apply the stated timeout policy.
Worksheet · LightMySky