6 #include "structdefs.h"
7 #include "RuntimeConflictResolver.h"
9 extern volatile int numWorkSchedWorkers;
11 struct trQueue * queuelist=NULL;
12 pthread_mutex_t queuelock;
16 //since if we reach SIZE, we will stop operation, it doesn't matter
17 //that we overwrite the element in the queue
18 void enqueueTR(struct trQueue *q, void * ptr) {
19 unsigned int head=q->head+1;
26 q->elements[head] = ptr;
31 void * dequeueTR(struct trQueue *q) {
32 unsigned int tail=q->tail;
40 void * ptr = q->elements[tail];
46 struct trQueue *ptr=NULL;
48 pthread_mutex_lock(&queuelock);
53 myid=numWorkSchedWorkers;
54 numWorkSchedWorkers++;
56 pthread_mutex_unlock(&queuelock);
60 pthread_attr_init(&nattr);
61 pthread_attr_setdetachstate( &nattr, PTHREAD_CREATE_DETACHED);
62 ptr=malloc(sizeof(struct trQueue));
66 ptr->allHashStructures=createAndFillMasterHashStructureArray();
67 int status=pthread_create( &thread, NULL, workerTR, (void *) ptr);
68 if (status!=0) {printf("ERROR\n");exit(-1);}
69 pthread_attr_destroy(&nattr);
75 //return worker thread to pool
76 pthread_mutex_lock(&queuelock);
77 TRqueue->next=queuelist;
79 pthread_mutex_unlock(&queuelock);
80 //release our worker thread