This circular buffer with blocking read/write is a near-exact model of the real Linux kernel pipe implementation in `fs/pipe.c`, which is exactly what makes `cat file | grep pattern` work without either program blocking forever. Getting the close-both-ends discipline wrong here reproduces a real, common bug: forgetting to close the unused pipe end in a forked child means the reader never sees EOF and hangs indefinitely, a classic shell-implementation gotcha.