Lines Matching +full:config +full:- +full:cond

2  * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
16 * - Redistributions of source code must retain the above
20 * - Redistributions in binary form must reproduce the above
43 # include <config.h>
57 pthread_cond_t cond; member
83 cl_qlist_init(&gp_timer_prov->queue); in __cl_timer_prov_create()
85 pthread_mutex_init(&gp_timer_prov->mutex, NULL); in __cl_timer_prov_create()
86 pthread_cond_init(&gp_timer_prov->cond, NULL); in __cl_timer_prov_create()
88 if (pthread_create(&gp_timer_prov->thread, NULL, in __cl_timer_prov_create()
104 tid = gp_timer_prov->thread; in __cl_timer_prov_destroy()
105 pthread_mutex_lock(&gp_timer_prov->mutex); in __cl_timer_prov_destroy()
106 gp_timer_prov->exit = TRUE; in __cl_timer_prov_destroy()
107 pthread_cond_broadcast(&gp_timer_prov->cond); in __cl_timer_prov_destroy()
108 pthread_mutex_unlock(&gp_timer_prov->mutex); in __cl_timer_prov_destroy()
112 pthread_mutex_destroy(&gp_timer_prov->mutex); in __cl_timer_prov_destroy()
113 pthread_cond_destroy(&gp_timer_prov->cond); in __cl_timer_prov_destroy()
128 pthread_mutex_lock(&gp_timer_prov->mutex); in __cl_timer_prov_cb()
129 while (!gp_timer_prov->exit) { in __cl_timer_prov_cb()
130 if (cl_is_qlist_empty(&gp_timer_prov->queue)) { in __cl_timer_prov_cb()
132 /* cond wait does: in __cl_timer_prov_cb()
135 * cond to be signaled. The thread execution is suspended and in __cl_timer_prov_cb()
139 * CALLING THREAD, PTHREAD_COND_WAIT RE-ACQUIRES MUTEX (as per in __cl_timer_prov_cb()
142 ret = pthread_cond_wait(&gp_timer_prov->cond, in __cl_timer_prov_cb()
143 &gp_timer_prov->mutex); in __cl_timer_prov_cb()
151 (cl_timer_t *) cl_qlist_head(&gp_timer_prov->queue); in __cl_timer_prov_cb()
153 pthread_cond_timedwait(&gp_timer_prov->cond, in __cl_timer_prov_cb()
154 &gp_timer_prov->mutex, in __cl_timer_prov_cb()
155 &p_timer->timeout); in __cl_timer_prov_cb()
170 if (p_timer->timer_state != CL_TIMER_QUEUED) in __cl_timer_prov_cb()
178 p_timer->timer_state = CL_TIMER_RUNNING; in __cl_timer_prov_cb()
181 cl_qlist_remove_item(&gp_timer_prov->queue, in __cl_timer_prov_cb()
182 &p_timer->list_item); in __cl_timer_prov_cb()
183 pthread_mutex_unlock(&gp_timer_prov->mutex); in __cl_timer_prov_cb()
185 p_timer->pfn_callback((void *)p_timer->context); in __cl_timer_prov_cb()
188 pthread_mutex_lock(&gp_timer_prov->mutex); in __cl_timer_prov_cb()
193 if (p_timer->timer_state == CL_TIMER_RUNNING) in __cl_timer_prov_cb()
194 p_timer->timer_state = CL_TIMER_IDLE; in __cl_timer_prov_cb()
200 pthread_cond_signal(&p_timer->cond); in __cl_timer_prov_cb()
203 gp_timer_prov->thread = 0; in __cl_timer_prov_cb()
204 pthread_mutex_unlock(&gp_timer_prov->mutex); in __cl_timer_prov_cb()
212 p_timer->state = CL_UNINITIALIZED; in cl_timer_construct()
228 p_timer->pfn_callback = pfn_callback; in cl_timer_init()
229 p_timer->context = context; in cl_timer_init()
232 p_timer->timer_state = CL_TIMER_IDLE; in cl_timer_init()
235 pthread_cond_init(&p_timer->cond, NULL); in cl_timer_init()
237 p_timer->state = CL_INITIALIZED; in cl_timer_init()
245 CL_ASSERT(cl_is_state_valid(p_timer->state)); in cl_timer_destroy()
247 if (p_timer->state == CL_INITIALIZED) in cl_timer_destroy()
250 p_timer->state = CL_UNINITIALIZED; in cl_timer_destroy()
252 /* is it possible we have some threads waiting on the cond now? */ in cl_timer_destroy()
253 pthread_cond_broadcast(&p_timer->cond); in cl_timer_destroy()
254 pthread_cond_destroy(&p_timer->cond); in cl_timer_destroy()
264 return ((p_timeout1->tv_sec < p_timeout2->tv_sec) || in __cl_timer_is_earlier()
265 ((p_timeout1->tv_sec == p_timeout2->tv_sec) && in __cl_timer_is_earlier()
266 (p_timeout1->tv_nsec < p_timeout2->tv_nsec))); in __cl_timer_is_earlier()
286 CL_ASSERT(p_in_list->state == CL_INITIALIZED); in __cl_timer_find()
287 CL_ASSERT(p_new->state == CL_INITIALIZED); in __cl_timer_find()
289 CL_ASSERT(p_in_list->timer_state == CL_TIMER_QUEUED); in __cl_timer_find()
291 if (__cl_timer_is_earlier(&p_in_list->timeout, &p_new->timeout)) in __cl_timer_find()
311 p_timer->tv_sec = endtime.tv_sec; in __cl_timer_calculate()
312 p_timer->tv_nsec = endtime.tv_usec * 1000; in __cl_timer_calculate()
321 CL_ASSERT(p_timer->state == CL_INITIALIZED); in cl_timer_start()
323 pthread_mutex_lock(&gp_timer_prov->mutex); in cl_timer_start()
325 pthread_cond_signal(&gp_timer_prov->cond); in cl_timer_start()
328 if (p_timer->timer_state == CL_TIMER_QUEUED) in cl_timer_start()
329 cl_qlist_remove_item(&gp_timer_prov->queue, in cl_timer_start()
330 &p_timer->list_item); in cl_timer_start()
332 __cl_timer_calculate(time_ms, &p_timer->timeout); in cl_timer_start()
335 if (cl_is_qlist_empty(&gp_timer_prov->queue)) { in cl_timer_start()
337 cl_qlist_insert_head(&gp_timer_prov->queue, in cl_timer_start()
338 &p_timer->list_item); in cl_timer_start()
341 p_list_item = cl_qlist_find_from_tail(&gp_timer_prov->queue, in cl_timer_start()
345 cl_qlist_insert_next(&gp_timer_prov->queue, p_list_item, in cl_timer_start()
346 &p_timer->list_item); in cl_timer_start()
349 p_timer->timer_state = CL_TIMER_QUEUED; in cl_timer_start()
350 pthread_mutex_unlock(&gp_timer_prov->mutex); in cl_timer_start()
358 CL_ASSERT(p_timer->state == CL_INITIALIZED); in cl_timer_stop()
360 pthread_mutex_lock(&gp_timer_prov->mutex); in cl_timer_stop()
361 switch (p_timer->timer_state) { in cl_timer_stop()
364 pthread_cond_wait(&p_timer->cond, &gp_timer_prov->mutex); in cl_timer_stop()
366 if (p_timer->timer_state != CL_TIMER_QUEUED) in cl_timer_stop()
371 p_timer->timer_state = CL_TIMER_IDLE; in cl_timer_stop()
373 cl_qlist_remove_item(&gp_timer_prov->queue, in cl_timer_stop()
374 &p_timer->list_item); in cl_timer_stop()
379 pthread_cond_signal(&gp_timer_prov->cond); in cl_timer_stop()
385 pthread_mutex_unlock(&gp_timer_prov->mutex); in cl_timer_stop()
395 CL_ASSERT(p_timer->state == CL_INITIALIZED); in cl_timer_trim()
397 pthread_mutex_lock(&gp_timer_prov->mutex); in cl_timer_trim()
401 if (p_timer->timer_state == CL_TIMER_QUEUED) { in cl_timer_trim()
403 if (__cl_timer_is_earlier(&p_timer->timeout, &newtime)) { in cl_timer_trim()
404 pthread_mutex_unlock(&gp_timer_prov->mutex); in cl_timer_trim()
411 pthread_mutex_unlock(&gp_timer_prov->mutex); in cl_timer_trim()