]> git.ipfire.org Git - thirdparty/glibc.git/commit
nptl: Use all of g1_start and g_signals
authorMalte Skarupke <malteskarupke@fastmail.fm>
Wed, 4 Dec 2024 13:05:40 +0000 (08:05 -0500)
committerCarlos O'Donell <carlos@redhat.com>
Mon, 28 Apr 2025 16:52:17 +0000 (12:52 -0400)
commit7f71824b8039b8afc150dd5c881b61faf10675ef
tree63acf89160e3531f93f498cc42417f6c95326d25
parent2ad69497346cc20ef4d568108f1de49b2f451c55
nptl: Use all of g1_start and g_signals

The LSB of g_signals was unused. The LSB of g1_start was used to indicate
which group is G2. This was used to always go to sleep in pthread_cond_wait
if a waiter is in G2. A comment earlier in the file says that this is not
correct to do:

 "Waiters cannot determine whether they are currently in G2 or G1 -- but they
  do not have to because all they are interested in is whether there are
  available signals"

I either would have had to update the comment, or get rid of the check. I
chose to get rid of the check. In fact I don't quite know why it was there.
There will never be available signals for group G2, so we didn't need the
special case. Even if there were, this would just be a spurious wake. This
might have caught some cases where the count has wrapped around, but it
wouldn't reliably do that, (and even if it did, why would you want to force a
sleep in that case?) and we don't support that many concurrent waiters
anyway. Getting rid of it allows us to use one more bit, making us more
robust to wraparound.

Signed-off-by: Malte Skarupke <malteskarupke@fastmail.fm>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 91bb902f58264a2fd50fbce8f39a9a290dd23706)
nptl/pthread_cond_broadcast.c
nptl/pthread_cond_common.c
nptl/pthread_cond_signal.c
nptl/pthread_cond_wait.c