[cgl_discussion] Question for TEMs/ISVs/OEMs regarding pthread
requirements
Corey Minyard
cminyard at mvista.com
Fri Jan 31 20:09:05 PST 2003
Stephen Hemminger wrote:
>>purpose of the whole thing :-).
>>
>>Also, I don't think it's possible to do the userland-only lock on a
>>machine that doesn't have compare-and-swap (MIPS, ARM, and old x86s
>>don't have it, for instance). I've spent some time thinking about it,
>>and I don't have a solution. It will be hard to get the kernel
>>maintainers to take something that is not generic.
>>
>>
>>
>
>There is way to do it without atomic read-modify-write it is called
>Dekker's Algorithm. Not pretty, and slower but it works.
>
>http://www.csee.wvu.edu/~jdm/classes/cs356/notes/mutex/Dekker.html
>
>
>
>
I don't think that will work in this case. All the processors have
test-and-set-bit instructions. You need a compare-and-swap instruction
(or the equivalent), which is a different (and much more powerful)
operation.
The problem with this algorithm is that it doesn't work if the processes
are running at different priority. It's basically a busy-spinloop, and
is useful for inside an operating system. But with processes, the
higher-priority process would spin forever.
-Corey
More information about the cgl_discussion
mailing list