LIU Hao wrote:

> 在 2026-9-9 19:11, Kirill Makurin 写道:
>> I really don't like dealing with code like this:
>>
>> 1. We will "signal" before second thread calls `pthread_mutex_lock` again, 
>> the one which deadlocks
>> 2. Once "signaled", main thread calls `pthread_mutex_unlock` so that second 
>> thread can grab lock again
>> and continue execution
>>
>> It is possible, though unlikely, that main will unlock the mutex before 
>> second thread deadlocks by
>> entering the wait state; that would result in a deadlock in main. I wrote 
>> code that accounts for it, that
>> is no problem, although I don't like how unnecessary messier it gets.
>>
>> I thought maybe it would be acceptable to simply return 77 (report test as 
>> skipped), instead of
>> assert'ing, if call to `pthread_mutex_trylock` does not return EBUSY? I did 
>> not see original version to
>> assert in either local testing or CI.
>
> How about this?
>
>     while (pthread_mutex_trylock (&mutex) == 0) {
>       pthread_mutex_unlock (&mutex);
>       Sleep(100);
>    }

I'll go with my change for now. I'll push new version for CI run later today, 
and if it passes, I'll send it to the list.

- Kirill Makurin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to