make sure the other thread doesn't just fall asleep
authorbdemsky <bdemsky>
Wed, 6 Aug 2008 05:42:03 +0000 (05:42 +0000)
committerbdemsky <bdemsky>
Wed, 6 Aug 2008 05:42:03 +0000 (05:42 +0000)
Robust/src/Runtime/DSTM/interface/queue.c

index 9ff96430dbdcf305ef5f3072e62f0aed5a08378a..507cf65811da40fbf2619fead2e6338e6f098d90 100644 (file)
@@ -25,17 +25,23 @@ void * getmemory(int size) {
   if (tmpoffset>QSIZE) {
     //Wait for tail to go past end
     tmpoffset=size+sizeof(int);
-    if (headoffset<tailoffset)
+    if (headoffset<tailoffset) {
+      pthread_cond_signal(&qcond);//wake the other thread up
       return NULL;
+    }
     //Wait for tail to go past new start
-    if (tailoffset<=tmpoffset)
+    if (tailoffset<=tmpoffset) {
+      pthread_cond_signal(&qcond);//wake the other thread up
       return NULL;
+    }
     *((int *)(memory+headoffset))=-1;//safe because we left space
     *((int*)memory)=size+sizeof(int);
     return memory+sizeof(int);
   } else {
-    if (headoffset<tailoffset&&tailoffset<=tmpoffset)
+    if (headoffset<tailoffset&&tailoffset<=tmpoffset) {
+      pthread_cond_signal(&qcond);//wake the other thread up
       return NULL;
+    }
     *((int*)(memory+headoffset))=size+sizeof(int);
     return memory+headoffset+sizeof(int);
   }