summaryrefslogtreecommitdiff
path: root/ot_mutex.c
diff options
context:
space:
mode:
authorerdgeist <>2009-01-16 02:26:50 +0000
committererdgeist <>2009-01-16 02:26:50 +0000
commitf12fa4c36216e83246767a3cff8dbc86e7d7c6eb (patch)
tree989508ccc92346c03ccc02d55a84344165c2ad8b /ot_mutex.c
parent66c906d5d3c100e5fe1e6f088bd1ea17c5831894 (diff)
Use a self pipe to wake from io_wait when a thread finished his work.
Diffstat (limited to 'ot_mutex.c')
-rw-r--r--ot_mutex.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 2ed5e81..0127721 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -32,6 +32,9 @@ static int bucket_locklist_count = 0;
32static pthread_mutex_t bucket_mutex; 32static pthread_mutex_t bucket_mutex;
33static pthread_cond_t bucket_being_unlocked; 33static pthread_cond_t bucket_being_unlocked;
34 34
35/* Self pipe from opentracker.c */
36extern int g_self_pipe[2];
37
35static int bucket_check( int bucket ) { 38static int bucket_check( int bucket ) {
36 /* C should come with auto-i ;) */ 39 /* C should come with auto-i ;) */
37 int i; 40 int i;
@@ -255,6 +258,8 @@ void mutex_workqueue_pushsuccess( ot_taskid taskid ) {
255 258
256int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iovec *iovec ) { 259int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iovec *iovec ) {
257 struct ot_task * task; 260 struct ot_task * task;
261 const char byte = 'o';
262
258 /* Want exclusive access to tasklist */ 263 /* Want exclusive access to tasklist */
259 MTX_DBG( "pushresult locks.\n" ); 264 MTX_DBG( "pushresult locks.\n" );
260 pthread_mutex_lock( &tasklist_mutex ); 265 pthread_mutex_lock( &tasklist_mutex );
@@ -275,6 +280,8 @@ int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iove
275 pthread_mutex_unlock( &tasklist_mutex ); 280 pthread_mutex_unlock( &tasklist_mutex );
276 MTX_DBG( "pushresult unlocked.\n" ); 281 MTX_DBG( "pushresult unlocked.\n" );
277 282
283 io_trywrite( g_self_pipe[1], &byte, 1 );
284
278 /* Indicate whether the worker has to throw away results */ 285 /* Indicate whether the worker has to throw away results */
279 return task ? 0 : -1; 286 return task ? 0 : -1;
280} 287}