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

Do Not Share, Just Send Word

Computing · Computer Systems · ages 21-22
Name ______________________   Date ____________
  1. A bounded queue is full and the producer keeps sending. What happens next?

    • The producer faces back pressure: it waits, or messages are dropped or refused
    • Messages speed up to make room
    • The consumer quietly deletes old messages
  2. In a message-passing design, who may touch a piece of state?

    • Any thread holding the right lock
    • Only its single owner
    • The thread that arrives first
  3. In the message-passing counter, two senders can still race on the counter value.

    Circle one:   True   False

  4. Your producer outruns your consumer and the queue drops new messages. What is the right response?

    • Send even faster to clear the backlog
    • Share the counter between threads instead
    • Slow the producer, speed the consumer, or size the queue on purpose
  5. An owner starts at 0 and handles add 1, add 1, add 2 in order. What is the final count?

    • 3
    • 4
    • 5
  6. Which comparison of the two designs is fair?

    • Shared memory risks races and deadlocks, while message passing risks full queues and ordering surprises
    • Message passing removes every possible failure
    • Both designs fail in exactly the same ways
  7. Events from two producers must be handled in exact order, but they share one queue. What should you conclude?

    • One shared queue guarantees global order by itself
    • Message passing removes all ordering questions
    • Ordering across producers needs extra design, like stamps or a single sequencer
  8. To gain speed, a teammate lets senders write the counter directly while keeping the queue. What breaks?

    • Nothing breaks; this is the recommended design
    • The race returns, because the state is shared again
    • Messages arrive in perfect order from then on
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. The producer faces back pressure: it waits, or messages are dropped or refused · A full buffer pushes back. The exact response follows the policy you chose.
  2. Only its single owner · One owner per state is the whole design. Everyone else sends messages.
  3. False · Senders never touch the counter. Only the owner applies messages, one at a time.
  4. Slow the producer, speed the consumer, or size the queue on purpose · Drops signal overload. Fix the balance deliberately instead of pushing harder.
  5. 4 · Apply each note in turn: 0 to 1, to 2, to 4.
  6. Shared memory risks races and deadlocks, while message passing risks full queues and ordering surprises · Each road has its own bug family. Pick the trade you would rather handle.
  7. Ordering across producers needs extra design, like stamps or a single sequencer · Arrival order at one queue is an accident of timing. Exact order needs deliberate design.
  8. The race returns, because the state is shared again · Direct writes make the counter shared. The lock-free safety depended on single ownership.
Worksheet · LightMySky