All other functions wait for `sema_b` with `waiters_count_lock_` locked.
The order of acquisition of these two things must happen in the same order
in all functions, otherwise deadlocks may happen.
The obvious fix is to make wait functions wait for the semaphore after
having locked `waiters_count_
在 2019/4/12 9:49, Andrew Ng 写道:
> I have attached a minimal patch that fixes the deadlock issue.
>
> The principle change to avoid deadlock, is to not wait whilst holding
> the "waiters count lock". Because of this change to the locking, there
> is an additional case required in the "signal" and "
Signed-off-by: Liu Hao
---
mingw-w64-libraries/winpthreads/src/cond.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mingw-w64-libraries/winpthreads/src/cond.c
b/mingw-w64-libraries/winpthreads/src/cond.c
index 368ee8a7..8df395eb 100644
--- a/mingw-w64-libraries/winpthreads/src/cond.c
+++