New essay: The Best Synchronization is No Synchronization
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 06 Jun 2007 01:52:14 -0400
In response to an earlier post saying that messages should not be used for synchronization
and that primitives like mutexes, events, and semaphores were better suited, (note also
that CRITICAL_SECTIONs had been omitted from the list, probably an oversight, and timers
had been included, for reasons I cannot ascertain because timers have nothing to do with
synchronization). I offer a counterargument: these primitives are the assembly code of
synchronization, and mechanisms like messages and I/O Completion Ports provide much better
alternatives most of the time. We should be searching for higher-level mechanisms.
I discuss two of my favorite non-synchronization mechanisms for mutual exclusion: the
Positive Handoff Protocol and the Central Controller Protocol, both of which are easier to
use and neither of which uses an event, semaphore, mutex, or CRITICAL_SECTION. I also
suggest that when these *are* needed they should be hidden inside classes so the
programmer never needs to see them.
http://www.flounder.com/no_synchronization.htm
joe
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: New essay: The Best Synchronization is No Synchronization
- From: Norman Diamond
- Re: New essay: The Best Synchronization is No Synchronization
- From: Tom Serface
- Re: New essay: The Best Synchronization is No Synchronization
- From: MrAsm
- Re: New essay: The Best Synchronization is No Synchronization
- Prev by Date: Re: How to PostThreadMessages?
- Next by Date: Re: passing file name
- Previous by thread: Background Processing in an MFC application
- Next by thread: Re: New essay: The Best Synchronization is No Synchronization
- Index(es):
Relevant Pages
|