X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Fqueue.c;h=c9db454db1e2a44990cc36c29d50d6ffd4417471;hb=d849edf3841c1c9774c5ce209a2b903415f2370a;hp=3577c783dba00b5d042a8c69140596d09c8d9171;hpb=178cf493d009995b28fdf220f04c98860ff79a9b;p=vpp.git diff --git a/src/svm/queue.c b/src/svm/queue.c index 3577c783dba..c9db454db1e 100644 --- a/src/svm/queue.c +++ b/src/svm/queue.c @@ -2,7 +2,7 @@ *------------------------------------------------------------------ * svm_queue.c - unidirectional shared-memory queues * - * Copyright (c) 2009 Cisco and/or its affiliates. + * Copyright (c) 2009-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -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_lock (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);