← Questions
Bounded blocking queue
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Implement a first-in, first-out queue with a fixed capacity that producer and consumer threads share. put blocks while the queue is full and take blocks while it is empty, and waiting threads must sleep rather than spin. Use a lock with condition variables (or semaphores), handle spurious wakeups, and explain why your code cannot lose a wakeup or deadlock. Follow-ups may include timeouts on put and take and shutting the queue down cleanly.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
