Preparing your design workspace

Loading the problem and your saved attempt…

Shared-Memory Single-Writer Single-Reader Channel

Design a bounded shared-memory message channel between two processes, with safe record ownership, FIFO delivery and explicit full, empty and drained outcomes.

Design the objects, interfaces and coordination protocol for one writer process and one reader process communicating through shared memory. For this exercise, assume a coordinator has already created and initialized one mapped region with a fixed positive record capacity and a fixed positive maximum message size.

The processes may map the region at different virtual addresses and use the same agreed layout; each endpoint has only one active caller. The writer sends finite byte messages and the reader receives independent copies in accepted-send order.

Storage must be reusable after a receive, and an accepted message must not be overwritten, lost or returned twice while both processes remain alive. Send reports Sent, Full, Closed or TooLarge; receive reports Message, Empty or Closed. Full, Empty and TooLarge change no channel state.

These operations do not wait for queue capacity or data, although brief internal synchronization is allowed. The writer may close its endpoint idempotently: later sends are rejected, accepted messages still drain, and the reader sees Closed only once closed and empty.

Caller buffers may be reused after successful send or receive. For this exercise, exclude process crashes/restarts, durable recovery, multiple writers/readers, TCP/network transport and zero-copy buffer leases.

Choose a synchronization mechanism supported across processes and explain how it protects complete-message publication and safe storage reuse. No implementation is required. In the final follow-up, add an optional waiting receive that avoids continuous polling while preserving the same message and close semantics.

The source reports only the one-writer/one-reader shared-memory protocol; capacity, message results, ownership, lifecycle and the waiting follow-up are practice assumptions.