Subj : Re: Insane "Metered Section" example on MSDN To : comp.programming.threads From : Uenal Mutlu Date : Tue Apr 19 2005 01:47 pm "Agresao" wrote > I was trying to implement a semaphore that won't always do a kernel > transition to a Win32 object and came up with some code that seemed to > work. Then I found this article on MSDN about this thing called a > "metered section": http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndllpro/html/ms dn_metrsect.asp > > The code sample looked very similar to my own efforts which sort of > made me think that my solution was correct. However by thinking a > little deeper one realizes that their design has a terrible race > condition, in which threads are blocked waiting for an auto-reset event > to be signaled when there's nobody to signal it. Testing showed that > this actually happens. Because it said that the metered section is faster than the CriticalSection of Win32, some days ago I had inspected the code visually, but I had my doubts that this can be any faster. Good to know about your experience. Luckily I have not wasted my time for doing some lengthy suitability and performance tests. BTW, is your code somehow freely available? > I'm sure some of you have seen this article before and talked about it, > but what puzzles me is that it has been in MSDN since 1998 and nobody > has bothered to revise it... My conclusion about MSDN is that, though not all, but most of the so called technical articles therein are simply useless or buggy stuff. Mostly it is hype for their new product versions' features or references to books of MS Press, but I think I'm not telling you something new here. .