http://qs1969.pair.com?node_id=1009043


in reply to Re^3: flock on Windows : process killed while in critical region
in thread flock on Windows : process killed while in critical region

On some Windows machines, Sleep 0 (the Win32 C call) has a habit of NOT releasing the time slot for efficiency reasons in the NT kernel to avoid excess context switches and per CPU cache locality (don't move threads or processes between CPUs unless high CPU usage). Sometimes until the timeslot expires (hardware interrupt), Sleep 0 will not release the timeslot and will just spin and the other thread remains frozen and the lock hasn't been released yet so your first thread is spinning in Sleep 0 burning CPU and the process seems deadlocked for many ms.