RE: [GD-Windows] TryEnterCriticalSection
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2002-01-04 21:56:53
|
> It seems to me that the best approach is use OS locks and minimize the > time locks are held. Am I missing something here? The non-blocking FIFO is supposed to be sized big enough that "normal" operating conditions always leaves free space in it. Thus, the normal case is to pay no additional cost except the memory bus atomic instruction cost, which is small for most architectures (compared to entering the kernel -- ouch!) You can get some of the same benefits by wrapping your blocking kernel primitive in an atomic memory primitive, and only call into the kernel when you actually need to block; assuming low contention this is a win. When we did BeOS, we called this pattern a "benaphore"; you might turn up something with a web search on that term. Cheers, / h+ |