* sysdeps/mips/pspinlock.c: Implement spinlocks.

2000-05-31  Andreas Jaeger  <aj@suse.de>

	* sysdeps/mips/pspinlock.c: Implement spinlocks.
This commit is contained in:
Andreas Jaeger 2000-05-31 12:21:21 +00:00
parent c3e485f12a
commit a3a99e0165
2 changed files with 34 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2000-05-31 Andreas Jaeger <aj@suse.de>
* sysdeps/mips/pspinlock.c: Implement spinlocks.
2000-05-28 Ulrich Drepper <drepper@redhat.com> 2000-05-28 Ulrich Drepper <drepper@redhat.com>
* spinlock.c (__pthread_lock): Remove ASSERT. * spinlock.c (__pthread_lock): Remove ASSERT.

View File

@ -21,10 +21,28 @@
#include <pthread.h> #include <pthread.h>
/* This implementation is similar to the one used in the Linux kernel. */
int int
__pthread_spin_lock (pthread_spinlock_t *lock) __pthread_spin_lock (pthread_spinlock_t *lock)
{ {
XXX unsigned int tmp;
asm volatile
(".set\tnoreorder\t\t\t# spin_lock\n"
".set\tpush\n"
".set\tmips2\n"
"1:\tll\t%1, %2\n\t"
"bnez\t%1, 1b\n\t"
" li\t%1, 1\n\t"
"sc\t%1, %0\n\t"
"beqz\t%1, 1b\n\t"
".set\tpop\n"
".set\treorder"
: "=o" (*lock), "=&r" (tmp)
: "o" (*lock)
: "memory");
return 0;
} }
weak_alias (__pthread_spin_lock, pthread_spin_lock) weak_alias (__pthread_spin_lock, pthread_spin_lock)
@ -32,7 +50,8 @@ weak_alias (__pthread_spin_lock, pthread_spin_lock)
int int
__pthread_spin_trylock (pthread_spinlock_t *lock) __pthread_spin_trylock (pthread_spinlock_t *lock)
{ {
XXX /* To be done. */
return 0;
} }
weak_alias (__pthread_spin_trylock, pthread_spin_trylock) weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@ -40,7 +59,14 @@ weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
int int
__pthread_spin_unlock (pthread_spinlock_t *lock) __pthread_spin_unlock (pthread_spinlock_t *lock)
{ {
XXX asm volatile
(".set\tnoreorder\t\t\t# spin_unlock\n\t"
"sw\t$0, %0\n\t"
".set\treorder"
: "=o" (*lock)
: "o" (*lock)
: "memory");
return 0;
} }
weak_alias (__pthread_spin_unlock, pthread_spin_unlock) weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@ -51,7 +77,7 @@ __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
/* We can ignore the `pshared' parameter. Since we are busy-waiting /* We can ignore the `pshared' parameter. Since we are busy-waiting
all processes which can access the memory location `lock' points all processes which can access the memory location `lock' points
to can use the spinlock. */ to can use the spinlock. */
XXX *lock = 1;
return 0; return 0;
} }
weak_alias (__pthread_spin_init, pthread_spin_init) weak_alias (__pthread_spin_init, pthread_spin_init)