diff options
| author | erdgeist <> | 2009-01-16 02:26:50 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-01-16 02:26:50 +0000 |
| commit | f12fa4c36216e83246767a3cff8dbc86e7d7c6eb (patch) | |
| tree | 989508ccc92346c03ccc02d55a84344165c2ad8b /ot_mutex.c | |
| parent | 66c906d5d3c100e5fe1e6f088bd1ea17c5831894 (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.c | 7 |
1 files changed, 7 insertions, 0 deletions
| @@ -32,6 +32,9 @@ static int bucket_locklist_count = 0; | |||
| 32 | static pthread_mutex_t bucket_mutex; | 32 | static pthread_mutex_t bucket_mutex; |
| 33 | static pthread_cond_t bucket_being_unlocked; | 33 | static pthread_cond_t bucket_being_unlocked; |
| 34 | 34 | ||
| 35 | /* Self pipe from opentracker.c */ | ||
| 36 | extern int g_self_pipe[2]; | ||
| 37 | |||
| 35 | static int bucket_check( int bucket ) { | 38 | static 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 | ||
| 256 | int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iovec *iovec ) { | 259 | int 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 | } |
