The API method InitializeCriticalSectionAndSpinCount
allows you to set a spin count so when EnterCriticalSection
is called, it loops using a spinlock to try to acquire the resource some number of times. Only if all the attempts fail does the thread transition to kernel mode to enter a wait state.
If the 'normal' InitializeCriticalSection()
is called instead, is there a 'default' spin count set? (Or is it 0, no spin?)
Quoting from this article:
SpinCount ... This field defaults to zero, but can be set to a different value with the
InitializeCriticalSectionAndSpinCount
API
So the default is no spin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With