Hacker News new | ask | show | jobs
by jhiesey 4402 days ago
I might be missing something, but the final version still looks susceptible to deadlock to me.

Suppose the buffer is empty. Process A, which is reading, gets through the mutex_unlock() call and into wait_event_interruptible(), which seems to first internally check the condition. It is then switched out before it internally waits.

Process B then runs all the way through, acquiring the mutex, doing its work, and runs wake_up_interruptible(), which won't do anything, because process A hasn't started waiting. Process B then releases the mutex and gets switched out.

Process A then gets switched back in, and then immediately starts waiting, with no more events to wake it up. Why won't it just wait forever (deadlock)?

Am I missing something? Do all processes occasionally get woken up without an explicit wake up?