On 2026-09-18 LIU Hao wrote:
> As for the critical section part, I think one can use dumb locks by
> defining `USE_WIN32_SL`; it avoids allocation and dynamic
> initialization.

The macro calls Sleep():

#define ACQUIRE_DTOA_LOCK(n) \
  while (InterlockedCompareExchange (&dtoa_sl[n], 1, 0) != 0) \
     Sleep (0);

Is it *guaranteed* that other threads will run before Sleep() returns?
On a single-processor system, it could deadlock if the scheduler doesn't
always switch to another thread on Sleep(0). It might be fine, I'm only
asking because I don't know.

When the lock is held, the code may call malloc(). So it's not just a
few simple instructions that are protected by the lock.

-- 
Lasse Collin


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

Reply via email to