From 55c4c85b99d476067caaa7a6802a7f97270d95a3 Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 27 Feb 2005 17:45:55 +0000 Subject: Change the spin lock logic to a reasonable one. We should spin when the lock is held by other thread, but not when nobody owns it. According to deischen@, this part of code will never be hit in our threads library, since it does not use locks without wait/wakeup functions. Spotted by: mingyanguo via ChinaUnix.net forum Reviewed by: deischen --- lib/libpthread/sys/lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libpthread/sys') diff --git a/lib/libpthread/sys/lock.c b/lib/libpthread/sys/lock.c index e65b552..0f0f5f9 100644 --- a/lib/libpthread/sys/lock.c +++ b/lib/libpthread/sys/lock.c @@ -183,7 +183,7 @@ _lock_acquire(struct lock *lck, struct lockuser *lu, int prio) atomic_store_rel_ptr(&lu->lu_watchreq->lr_watcher, lu); if ((lck->l_wait == NULL) || ((lck->l_type & LCK_ADAPTIVE) == 0)) { - while (lu->lu_watchreq->lr_locked == 0) + while (lu->lu_watchreq->lr_locked != 0) ; /* spin, then yield? */ } else { /* -- cgit v1.1