summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_spinlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libkse/thread/thr_spinlock.c')
-rw-r--r--lib/libkse/thread/thr_spinlock.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/libkse/thread/thr_spinlock.c b/lib/libkse/thread/thr_spinlock.c
index ad7b222..cb71a46 100644
--- a/lib/libkse/thread/thr_spinlock.c
+++ b/lib/libkse/thread/thr_spinlock.c
@@ -41,9 +41,14 @@
#include <unistd.h>
#include <libc_private.h>
-
+#include "spinlock.h"
#include "thr_private.h"
+/*
+ * These are for compatability only. Spinlocks of this type
+ * are deprecated.
+ */
+
void
_spinunlock(spinlock_t *lck)
{
@@ -60,20 +65,14 @@ _spinunlock(spinlock_t *lck)
void
_spinlock(spinlock_t *lck)
{
- struct pthread *curthread = _get_curthread();
-
/*
* Try to grab the lock and loop if another thread grabs
* it before we do.
*/
while(_atomic_lock(&lck->access_lock)) {
- /* Block the thread until the lock. */
- curthread->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, __FILE__, __LINE__);
+ while (lck->access_lock)
+ ;
}
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) curthread;
}
/*
@@ -89,30 +88,12 @@ _spinlock(spinlock_t *lck)
void
_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
{
- struct pthread *curthread = _get_curthread();
- int cnt = 0;
-
/*
* Try to grab the lock and loop if another thread grabs
* it before we do.
*/
while(_atomic_lock(&lck->access_lock)) {
- cnt++;
- if (cnt > 100) {
- char str[256];
- snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", getprogname(), curthread, lck, fname, lineno, lck->fname, lck->lineno);
- __sys_write(2,str,strlen(str));
- __sleep(1);
- cnt = 0;
- }
-
- /* Block the thread until the lock. */
- curthread->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, fname, lineno);
+ while (lck->access_lock)
+ ;
}
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) curthread;
- lck->fname = fname;
- lck->lineno = lineno;
}
OpenPOWER on IntegriCloud