summaryrefslogtreecommitdiff
path: root/linuxthreads/spinlock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-29 15:17:25 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-29 15:17:25 +0000
commitc5e340c71ba6f4563ca5fa245baa82b6363ddb2e (patch)
tree3ff655dfee624df411e1f3ebc062181fc0f3f338 /linuxthreads/spinlock.c
parent05e951cd1ae7917ce25ec96cc17ebcbf401e345c (diff)
Update.
1998-10-29 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/ttyname_r.c (ttyname_r): Try reading /prof/self/fd/FD first. * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Likewise. * stdio-common/_itoa.h (_fitoa_word): New inline function. Write formatted number starting at given position and return pointer to following byte. (_fitoa): Likewise, for long long.
Diffstat (limited to 'linuxthreads/spinlock.c')
-rw-r--r--linuxthreads/spinlock.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/linuxthreads/spinlock.c b/linuxthreads/spinlock.c
index 172cb7afe4..00a8691e5b 100644
--- a/linuxthreads/spinlock.c
+++ b/linuxthreads/spinlock.c
@@ -36,17 +36,18 @@
This is safe because there are no concurrent __pthread_unlock
operations -- only the thread that locked the mutex can unlock it. */
-void __pthread_lock(struct _pthread_fastlock * lock)
+void internal_function __pthread_lock(struct _pthread_fastlock * lock,
+ pthread_descr self)
{
long oldstatus, newstatus;
- pthread_descr self = NULL;
do {
oldstatus = lock->__status;
if (oldstatus == 0) {
newstatus = 1;
} else {
- self = thread_self();
+ if (self == NULL)
+ self = thread_self();
newstatus = (long) self;
}
if (self != NULL)
@@ -56,18 +57,7 @@ void __pthread_lock(struct _pthread_fastlock * lock)
if (oldstatus != 0) suspend(self);
}
-int __pthread_trylock(struct _pthread_fastlock * lock)
-{
- long oldstatus;
-
- do {
- oldstatus = lock->__status;
- if (oldstatus != 0) return EBUSY;
- } while(! compare_and_swap(&lock->__status, 0, 1, &lock->__spinlock));
- return 0;
-}
-
-void __pthread_unlock(struct _pthread_fastlock * lock)
+void internal_function __pthread_unlock(struct _pthread_fastlock * lock)
{
long oldstatus;
pthread_descr thr, * ptr, * maxptr;