Skip to main content

Practice · 2 of 4

Bounded FIFO Queue

CHALLENGE
Difficulty: advanced+25 XP

Given: mutex, condvar, int slots[8], head/tail/count. Implement int qpush(int v) (append FIFO; -1 when full) and int qpop(void) (remove oldest; -1 when empty). Push/pop must maintain the mutex and the invariant count equals live elements.

Back to lesson: Practice: Synchronization Drills