Browse Source

Yield after releasing a lock in case we are on a device with limited CPU resources.

Conflicts:
	miner.h
Con Kolivas 12 years ago
parent
commit
e32feb9261
1 changed files with 3 additions and 0 deletions
  1. 3 0
      miner.h

+ 3 - 0
miner.h

@@ -26,6 +26,7 @@
 #include <pthread.h>
 #include <jansson.h>
 #include <curl/curl.h>
+#include <sched.h>
 
 #include <blkmaker.h>
 #include <blktemplate.h>
@@ -738,6 +739,7 @@ static inline void mutex_unlock(pthread_mutex_t *lock)
 {
 	if (unlikely(pthread_mutex_unlock(lock)))
 		quit(1, "WTF MUTEX ERROR ON UNLOCK!");
+	sched_yield();
 }
 
 static inline int mutex_trylock(pthread_mutex_t *lock)
@@ -761,6 +763,7 @@ static inline void rw_unlock(pthread_rwlock_t *lock)
 {
 	if (unlikely(pthread_rwlock_unlock(lock)))
 		quit(1, "WTF RWLOCK ERROR ON UNLOCK!");
+	sched_yield();
 }
 
 static inline void rd_unlock(pthread_rwlock_t *lock)