43 pthread_mutex_t alloc_lock;
52get_next_task(
task_queue_t * tq) __attribute__((always_inline));
62 pthread_mutex_lock(&tq->lock);
69 pthread_mutex_unlock(&tq->lock);
78 pthread_mutex_lock(&tq->lock);
82 pthread_mutex_unlock(&tq->lock);
88task_queue_get_atomic(
task_queue_t * tq) __attribute__((always_inline));
94 __attribute__((always_inline));
103 __attribute__((always_inline));
108task_queue_get_slot_atomic(
task_queue_t * tq) __attribute__((always_inline));
112task_queue_get_slot(
task_queue_t * tq) __attribute__((always_inline));
116task_queue_init(
int alloc_size);
127 pthread_mutex_lock(&tq->lock);
131 tq->head = ret->next;
134 pthread_mutex_unlock(&tq->lock);
143 pthread_mutex_lock(&tq->lock);
147 pthread_mutex_unlock(&tq->lock);
233 pthread_mutex_lock(&tq->lock);
234 task_t * slot = task_queue_get_slot(tq);
236 task_queue_add(tq, slot);
237 pthread_mutex_unlock(&tq->lock);
246 if(l->curr < tq->alloc_size) {
247 ret = &(l->tasks[l->curr]);
252 nl->tasks = (
task_t*) malloc(tq->alloc_size *
sizeof(
task_t));
254 nl->next = tq->free_list;
256 ret = &(nl->tasks[0]);
267 pthread_mutex_lock(&tq->alloc_lock);
268 task_t * ret = task_queue_get_slot(tq);
269 pthread_mutex_unlock(&tq->alloc_lock);
276task_queue_init(
int alloc_size)
280 ret->free_list->tasks = (
task_t*) malloc(alloc_size *
sizeof(
task_t));
281 ret->free_list->curr = 0;
282 ret->free_list->next = NULL;
284 ret->alloc_size = alloc_size;
286 pthread_mutex_init(&ret->lock, NULL);
287 pthread_mutex_init(&ret->alloc_lock, NULL);
Provides general type definitions used by all join algorithms.