From: bdemsky Date: Wed, 13 May 2009 02:13:05 +0000 (+0000) Subject: various bug fixes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a50bd3298af52837561bcd28b6f59c51ee74d128;p=IRC.git various bug fixes --- diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index a30cb5f8..f6c43d68 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -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); } diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 4040c533..ec8ee1d8 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -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___) {