linux-sysprog · intermediate · ~15 min
Model a bounded producer/consumer queue.
A bounded buffer of capacity cap processes 'p' (produce, ignored if full) and 'c' (consume, ignored if empty). Implement int buffer_after(const char *ops, int cap) returning the item count at the end.
int buffer_after(const char *ops, int cap) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.