3 ms·
Agreed on Q4 — if understanding race conditions is what Colin was driving at, Q4 was simply a bad question for it. A better wording might be: "What surprising
by throwaway54-762 14y ago
Agreed on Q4 — if understanding race conditions is what Colin was driving at, Q4 was simply a bad question for it.
A better wording might be: "What surprising behavior could occur if `pthread_cond_wait` didn't take a locked mutex?"
(Full disclosure: I also scored a zero on Q4. However, I'm familiar with both pthreads and the necessary atomicity between releasing the lock and waiting on the condition, so this was a surprise. He was obviously fishing for a specific answer, but I couldn't figure out which from the question.)
- cperciva 14y agoI can't tell from your user name and your comment which person you are -- can you tell me what your answer was?
- throwaway54-762 14y agoSorry, I'm embarrassed now that I know what you were actually looking for. I will say: my answer did mention the need to atomically release the lock and then wait on the condition, but it was buried in a bunch of other crap that was not what you were looking for. If you really want, I'll send you an email — let me know.