linux-sysprog · intermediate · ~15 min
Track pipe occupancy as a producer/consumer count.
Model a byte pipe from an op string: 'w' writes one byte, 'r' reads one byte (ignored if the pipe is empty). Implement int pipe_bytes_available(const char *ops) returning how many bytes remain at the end.
int pipe_bytes_available(const char *ops) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.