[Top] [All Lists]

Re: patches for test-and-set without ll/sc (Re: thread-ready ABIs)

To: "Ralf Baechle" <>, "Machida Hiroyuki" <>
Subject: Re: patches for test-and-set without ll/sc (Re: thread-ready ABIs)
From: "Kevin D. Kissell" <>
Date: Fri, 25 Jan 2002 08:25:10 +0100
Cc: <>, <>, <>
References: <> <005301c1a368$87d27ed0$10eca8c0@grendel> <> <>
> > > It should in principle be SMP safe.
> > 
> > I don't think so.
> > 
> > Suppose that 
> > THREAD A is bound to CPU A and THREAD B is bound to CPU B.
> > THREAD A and THREAD B are running on_atomic_inc_nollsc(). 
> > Two threads are really running at the same time, without
> > context-switch. In this case nobody clear k1.
> There is a method for mutual exclusion called Dekker's Algorithem (sp?)
> which only requires just atomic stores and can be implemented in plain
> C.  Downside is it's weak performance that renders it pretty much a CS
> only thing.

Having actually ised Dekker's algorithm once in an industrial
application (2 Z80's with a shared buffer) some 20-odd years ago, 
I can say that it does work, but caution that, while in theory one can 
scale it to arbitrary number of CPUs, the time of the operation expands
by something like the square of the number of CPUs involved.
It's minimally acceptable for 2 CPUs.  More than that...

            Kevin K.

<Prev in Thread] Current Thread [Next in Thread>