Mercurial > hg > Gears > GearsAgda
diff src/parallel_execution/worker.c @ 95:3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 29 Jan 2016 05:36:52 +0900 |
parents | |
children | d400948dbbab |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/worker.c Fri Jan 29 05:36:52 2016 +0900 @@ -0,0 +1,29 @@ +#include <libkern/OSAtomic.h> + +#include "context.h" +#include "origin_cs.h" + +__code getQueue(struct Context* context, struct Queue* queue, struct Node* node) { + if (queue->first == 0) + return; + + struct Element* first = queue->first; +// if (__sync_bool_compare_and_swap(&queue->first, first, first->next)) { + if (OSAtomicCompareAndSwapPtr(first, first->next, (void*)&queue->first)) { + queue->count--; + + context->next = GetQueue; + stack_push(context->code_stack, &context->next); + + context->next = first->task->code; + node->key = first->task->key; + + goto meta(context, Get); + } else { + goto meta(context, GetQueue); + } +} + +__code getQueue_stub(struct Context* context) { + goto getQueue(context, &context->data[ActiveQueue]->queue, &context->data[Node]->node); +}