}
#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;
#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);
}
}
#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)
#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___) {