From 12927a851366fd52e494fc656c96574af18fc46e Mon Sep 17 00:00:00 2001 From: Xin LI 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') diff --git a/lib/libpthread/sys/lock.c b/lib/libpthread/sys/lock.c index e65b552ffaa3..0f0f5f9ce149 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.3