linuxthreads/spinlock.c bug
Kaz Kylheku
kaz@ashi.footprints.net
Wed Oct 17 10:53:00 GMT 2001
The wait_node_alloc an wait_node_free functions are braindamaged
because they naively implement a stack using compare_and_swap.
The problem is that when you remove a node, it's possible for
the compare_and_swap to succeed even if the list has changed,
just because the head pointer is identical. E.g. suppose
you evaluate the head pointer while the list looks like this:
X -> Y -> Z -> 0
Meanwhile some other threads comes along and do:
(pop X)
Y -> Z -> 0
(pop Y)
Z -> 0
(push X)
X -> Z -> 0
So now the original thread's compare_and_swap can still succeed, due
to the match on the X, even though the list is different now.
I propose to scrap the ``optimization'' in wait_node_alloc/free and just
use malloc/free directly.
More information about the Libc-alpha
mailing list