This question evaluates a candidate's understanding of concurrent programming, durable I/O, synchronization primitives, ordering guarantees, and system reliability under contention.
Design a log writer component that is called from multiple application threads and writes logs to a single file on disk.
Requirements:
log(message)
may be invoked by many threads.
log()
returns, the message must be persisted such that it survives a process crash (assume you must
fsync
/flush).
fsync
per message if possible.