Probably unnecessary InterlockedCompareExchangePointer in List_remove in thread.h

Vaclav Haisman V.Haisman@sh.cvut.cz
Mon May 30 18:00:00 GMT 2005


I am not sure, that is why I wrote "probably". But from what I see there is
already exclusive access guaranteed by the mx.lock() call, unless of course I
am completely misunderstanding something.

I can tell you that "lock; cmpxchg" pair of instruction is really not as cheap
as it looks. Especially on SMP systems. It takes above 100 of cycles on
contemporary CPUs.


VH



On Mon, 30 May 2005, Corinna Vinschen wrote:

> On May 29 17:03, Vaclav Haisman wrote:
> >
> > I think that the call to InterlockedCompareExchangePointer() can and should be
> > replaced by ordinary if and assignment. The synchronization it provides doesn't
> > seem to be necessary.
>
> Are you sure the synchronization isn't necessary?  You just say you think
> it isn't, but there's not much of a proof.  In any case, the call to
> InterlockedCompareExchangePointer is looking quite expensive, but it isn't.
> Did you notive there's a local file called winbase.h in the cygwin directory?
> If you have a look, you'll see that InterlockedCompareExchangePointer
> boils down to exactly one assembler instruction, so it doesn't seem to
> be worth the effort, does it?
>
>
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Project Co-Leader          mailto:cygwin@cygwin.com
> Red Hat, Inc.
>



More information about the Cygwin-patches mailing list