C
C#10mo ago
ethanrox

How does waiting on a locked object by a managed thread work exactly in .NET (Windows)

If we have a thread that is waiting to acquire a lock for a while and the thin lock of the locked object is promoted to a fat lock and a kernel object is created (sync block table etc) - what mechanism is used to wake up the waiting thread exactly?
3 Replies
mtreit
mtreit10mo ago
That's really an operating system question. I believe on Windows it uses a reset event
ethanrox
ethanroxOP10mo ago
okay, so the CLR communicates with the OS to create this kernel event by subscribing the waiting thread to it and the OS wakes up the waiting native thread that underlies the managed thread when the lock is freed?
mtreit
mtreit10mo ago
Basically yes.
Want results from more Discord servers?
Add your server