various bug fixes
authorbdemsky <bdemsky>
Wed, 13 May 2009 02:13:05 +0000 (02:13 +0000)
committerbdemsky <bdemsky>
Wed, 13 May 2009 02:13:05 +0000 (02:13 +0000)
Robust/src/Runtime/garbage.c
Robust/src/Runtime/thread.c

index a30cb5f84bf1482d006af78084245eae53a76669..f6c43d688cd1f5a75c5a7b9721a890a96d3abf09 100644 (file)
@@ -329,6 +329,20 @@ void collect(struct garbagelist * stackptr) {
   }
 #if defined(THREADS)||defined(DSTM)||defined(STM)
   /* Go to next thread */
+#ifndef MAC
+  //skip over us
+  if (listptr==&litem) {
+    listptr=listptr->next;
+  }
+#else
+ {
+  struct listitem *litem=pthread_getspecific(litemkey);
+  if (listptr==litem) {
+    listptr=listptr->next;
+  }
+ }
+#endif
+
   if (listptr!=NULL) {
 #ifdef THREADS
     void * orig=listptr->locklist;
@@ -628,7 +642,10 @@ void stopforgc(struct garbagelist * ptr) {
 #endif
   pthread_mutex_lock(&gclistlock);
   listcount++;
-  pthread_cond_signal(&gccond);
+  if ((listcount+1)==threadcount) {
+    //only do wakeup if we are ready to GC
+    pthread_cond_signal(&gccond);
+  }
   pthread_mutex_unlock(&gclistlock);
 }
 
index 4040c5335fed8e9fc7d6947d189666a386231d75..ec8ee1d896399eef3d55f8499a0fb1adf198800c 100644 (file)
@@ -165,6 +165,22 @@ void initializethreads() {
   }
 #endif
 #endif
+#ifdef MAC
+  struct listitem *litem=malloc(sizeof(struct listitem));
+  pthread_setspecific(litemkey, litem);
+  litem->prev=NULL;
+  litem->next=list;
+  if(list!=NULL)
+    list->prev=litem;
+  list=litem;
+#else
+  //Add our litem to list of threads
+  litem.prev=NULL;
+  litem.next=list;
+  if(list!=NULL)
+    list->prev=&litem;
+  list=&litem;
+#endif
 }
 
 #if defined(THREADS)||defined(STM)
@@ -307,17 +323,17 @@ transstart:
 
 #if defined(THREADS)||defined(STM)
 void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) {
+  pthread_mutex_lock(&joinlock);
+  while(!VAR(___this___)->___finished___) {
 #ifdef PRECISE_GC
   stopforgc((struct garbagelist *)___params___);
 #endif
-  pthread_mutex_lock(&joinlock);
-  while(!VAR(___this___)->___finished___)
     pthread_cond_wait(&joincond, &joinlock);
-  pthread_mutex_unlock(&joinlock);
 #ifdef PRECISE_GC
     restartaftergc();
 #endif
-
+  }
+  pthread_mutex_unlock(&joinlock);
 }
 
 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {