Fair thread synchronization RRS feed


  • That article is quite dated, published before the Whidbey project where a lot of work was done on the CLR.  The Rotor source code provides a hint, although syncblk.cpp is as rough as it comes.  I certainly don't understand half of what's there.  However, it looks clear to me that threads enter a FIFO queue when they wait for a lock.  And the code heavily interacts with the garbage collector.  I read a blurb somewhere that subsequent work was done on making lock waiting intentionally unfair to avoid problems with lock convoys.

    This is all pretty fuzzy, these CLR internals are hard to uncover.  However, I wouldn't lose any sleep over this being done properly, there's a heckofalot of code out there that depends on this working well.

    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, October 17, 2008 9:02 AM
    Tuesday, October 14, 2008 1:10 AM