Wednesday 16 April 2003 — This is over 21 years old. Be careful.
I’m annoyed by the fact that Win32 has two separate synchronization primitives, one called a mutex, and another called a critical section. I’m annoyed because these two work exactly the same, except one can be used across processes, and is therefore more heavyweight, than the other. Except for that, they are the same.
So why were they given those names? These are both mutexes. The name “critical section” doesn’t even make any sense for an allocated object that can be locked and unlocked. What is it a section of, and in what sense is it critical?
The name “critical section” comes from the concurrent programming idea of a chunk of code that cannot be entered simultaneously by more than one thread. It is a critical section of code. Of course, a mutex is a good way to protect a critical section, and critical sections need not be protected across processes, so you can see how the term came to be misused for a lightweight mutex.
The Win32 definition of the term is being presented as authoritative in some glossaries, which is unfortunate. If you’ve learned about thread programming on Win32, try to remember: Microsoft’s names for these things are a little off.
Comments
In retrospect, Microsoft should have called them something like "process" and "global" mutexs to make the distinction. Sun makes this sort of distinction with threads on Solaris -- there are "user" and "kernel" threads. The former is only for programmer convenience and not pre-emptive and can't be independently scheduled on different processors. Microsoft has made a similar weird name choice here: they have "threads" and "fibers". The latter are like "user threads" in Solaris.
--bob
Ole
Add a comment: