1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

* sysdeps/unix/sysv/linux/sem_post.c: Only wake threads if old

value of semaphore was zero.
	* sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sem_post.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.

	* sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Remove unnecessary
	extra cancellation test.
	* sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
This commit is contained in:
Ulrich Drepper
2007-05-15 06:24:31 +00:00
parent 1d47e92f71
commit 83d87915da
8 changed files with 50 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
/* sem_post -- post to a POSIX semaphore. Generic futex-using version.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
@@ -31,12 +31,14 @@ __new_sem_post (sem_t *sem)
{
int *futex = (int *) sem;
int nr = atomic_increment_val (futex);
int err = lll_futex_wake (futex, nr);
if (__builtin_expect (err, 0) < 0)
if (atomic_increment_val (futex) == 1)
{
__set_errno (-err);
return -1;
int err = lll_futex_wake (futex, 1);
if (__builtin_expect (err, 0) < 0)
{
__set_errno (-err);
return -1;
}
}
return 0;
}