linux-sysprog · beginner · ~15 min

Would the producer block?

Identify the producer back-pressure condition.

Challenge

Implement int producer_blocks(int count, int cap) returning 1 if the buffer is full (count >= cap), so the next produce must wait.

Starter code

int producer_blocks(int count, int cap) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.