diff options
author | Ping Yu <ping.yu@intel.com> | 2019-03-12 05:28:16 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-05-20 09:28:10 +0000 |
commit | a474894a4a39edd5dc96151e6f95f8122e06a450 (patch) | |
tree | bc21ebde9ae05a2ab09e92e85b0acccc1c57abc5 /src | |
parent | 09267f705f408c061e03d07a559efba661900f2d (diff) |
consolidate all mutux opertion
replace all pthread_mutex_lock/unlock to be svm_queue_lock/unlock
So there all operation is based on defined mutux, and it can help us
to debug or replace mutux locking method
Change-Id: I9aeeb03bbbbf3d7a824c06a535e5d6a6b463b42c
Signed-off-by: Ping Yu <ping.yu@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/svm/queue.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/svm/queue.c b/src/svm/queue.c index 4cc6658c9e7..2dd987b31b1 100644 --- a/src/svm/queue.c +++ b/src/svm/queue.c @@ -140,10 +140,10 @@ svm_queue_wait_inline (svm_queue_t * q) /* Fake a wait for event. We could use epoll but that would mean * using yet another fd. Should do for now */ u32 cursize = q->cursize; - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); while (q->cursize == cursize) CLIB_PAUSE (); - pthread_mutex_lock (&q->mutex); + svm_queue_lock (q); } } @@ -170,11 +170,11 @@ svm_queue_timedwait_inline (svm_queue_t * q, double timeout) u32 cursize = q->cursize; int rv; - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); while (q->cursize == cursize && unix_time_now () < max_time) CLIB_PAUSE (); rv = unix_time_now () < max_time ? 0 : ETIMEDOUT; - pthread_mutex_lock (&q->mutex); + svm_queue_unlock (q); return rv; } } @@ -250,13 +250,13 @@ svm_queue_add (svm_queue_t * q, u8 * elem, int nowait) } } else - pthread_mutex_lock (&q->mutex); + svm_queue_lock (q); if (PREDICT_FALSE (q->cursize == q->maxsize)) { if (nowait) { - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return (-2); } while (q->cursize == q->maxsize) @@ -277,7 +277,7 @@ svm_queue_add (svm_queue_t * q, u8 * elem, int nowait) if (need_broadcast) svm_queue_send_signal (q, 1); - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return 0; } @@ -300,13 +300,13 @@ svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait) } } else - pthread_mutex_lock (&q->mutex); + svm_queue_lock (q); if (PREDICT_FALSE (q->cursize + 1 == q->maxsize)) { if (nowait) { - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return (-2); } while (q->cursize + 1 == q->maxsize) @@ -336,7 +336,7 @@ svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait) if (need_broadcast) svm_queue_send_signal (q, 1); - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return 0; } @@ -361,13 +361,13 @@ svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond, } } else - pthread_mutex_lock (&q->mutex); + svm_queue_lock (q); if (PREDICT_FALSE (q->cursize == 0)) { if (cond == SVM_Q_NOWAIT) { - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return (-2); } else if (cond == SVM_Q_TIMEDWAIT) @@ -377,7 +377,7 @@ svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond, if (rc == ETIMEDOUT) { - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return ETIMEDOUT; } } @@ -404,7 +404,7 @@ svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond, if (need_broadcast) svm_queue_send_signal (q, 0); - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return 0; } @@ -415,10 +415,10 @@ svm_queue_sub2 (svm_queue_t * q, u8 * elem) int need_broadcast; i8 *headp; - pthread_mutex_lock (&q->mutex); + svm_queue_lock (q); if (q->cursize == 0) { - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); return -1; } @@ -431,7 +431,7 @@ svm_queue_sub2 (svm_queue_t * q, u8 * elem) if (PREDICT_FALSE (q->head == q->maxsize)) q->head = 0; - pthread_mutex_unlock (&q->mutex); + svm_queue_unlock (q); if (need_broadcast) svm_queue_send_signal (q, 0); |