[PATCH] Use C11 atomics instead atomic_decrement_and_test
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Sep 22 13:55:28 GMT 2022
Hi Adhemerval,
> + if (atomic_fetch_add_relaxed (&pthread->nr_refs, -1) != 1)
> return;
>
> /* Withdraw this thread from the thread ID lookup table. */
> Ok (and I am not sure why __pthread_create_internal usage does not use atomic at all).
Yes the non-atomic increment is a bug, an in/decrement could be lost if there is
a data race. Is it still used or could we default to nptl and remove the htl stuff?
> I am not sure if MO is suffice here, shouldn't it synchronize with the update
> from __pthread_create_internal?
As discussed in my previous mail, __pthread_total and __nptl_nthreads are simple
counters that decide when to call exit for the last thread.
> Ok, although this code is not used anywhere (neither for testing). Maybe it would be better
> to just remove it.
Yes, it looks like it was added 20 years ago as some kind of internal benchmark - I'll remove it
in the commit.
Cheers,
Wilco
More information about the Libc-alpha
mailing list