|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2006-03-01 16:50:33
Matt Hurd <matt.hurd_at_[hidden]> writes:
> On Thursday 02 March 2006 04:50, Anthony Williams wrote:
>> Matt Hurd <matt.hurd_at_[hidden]> writes:
>> >> > Any thoughts on this?
>> >>
>> >> Well, OS Mutexes might be recursive on Windows, but Critical Sections
>> >> aren't.
>> >
>> > Huh? I haven't programmed on windows for a bit but I'm pretty sure they
>> > are:
>>
>> I must be going mad. Of course, you're right.
>>
>> Anyway, my basic_mutex does not allow recursive locks --- you need
>> basic_recursive_mutex for that.
>
> OK.
>
> Then what is the advantage over wrapping a critical section up as the mutex /
> locking mechanism? It is fast, native to windows and recursive. And,
> perhaps more importantly, written and maintained by someone else ;-) The
> timings I did a few years ago suggested to me (from memory) that the cycle
> count on a windoze critical section wasn't much more than an atomic op.
The advantage is that you cannot statically initialize a critical section.
Anthony
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk