From: bdemsky Date: Mon, 11 Apr 2011 21:31:25 +0000 (+0000) Subject: changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=83eb50940e2e2f68c9a31c0ee4e5f5d468100041;p=IRC.git changes --- diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 61159ecd..f84e3fe8 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -15,6 +15,7 @@ #ifndef MAC __thread struct lockvector lvector; +__thread int mythreadid; #endif #ifdef D___Object______nativehashCode____ @@ -44,11 +45,12 @@ int CALL01(___Object______getType____, struct ___Object___ * ___this___) { void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) { #ifdef MAC struct lockvector *lptr=(struct lockvector *)pthread_getspecific(threadlocks); + int self=pthread_getspecific(macthreadid); #else struct lockvector *lptr=&lvector; + int self=mythreadid; #endif struct lockpair *lpair=&lptr->locks[lptr->index++]; - pthread_t self=pthread_self(); lpair->object=VAR(___this___); if (self==VAR(___this___)->tid) { @@ -87,6 +89,11 @@ void CALL01(___Object______notifyAll____, struct ___Object___ * ___this___) { #ifdef D___Object______wait____ void CALL01(___Object______wait____, struct ___Object___ * ___this___) { +#ifdef MAC + int self=pthread_getspecific(macthreadid); +#else + int self=mythreadid; +#endif pthread_t self=pthread_self(); int notifycount=VAR(___this___)->notifycount; BARRIER(); diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index b014f85d..cd7939f3 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -171,6 +171,7 @@ struct lockvector { #ifndef MAC extern __thread struct lockvector lvector; +extern __thread int mythreadid; #endif #ifdef TASK diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index c048e85e..f475c17e 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -46,6 +46,7 @@ pthread_mutex_t atomiclock; pthread_mutex_t joinlock; pthread_cond_t joincond; pthread_key_t threadlocks; +pthread_key_t macthreadid; pthread_mutex_t threadnotifylock; pthread_cond_t threadnotifycond; pthread_key_t oidval; @@ -173,6 +174,7 @@ void initializethreads() { pthread_mutex_init(&joinlock,NULL); pthread_cond_init(&joincond,NULL); #ifdef MAC + pthread_key_create(&macthreadid, NULL); pthread_key_create(&threadlocks, NULL); pthread_key_create(&litem, NULL); #endif @@ -250,6 +252,7 @@ void initializethreads() { litem->lockvector=lvector; lvector->index=0; pthread_setspecific(threadlocks, lvector); + pthread_setspecific(macthreadid, 0); pthread_setspecific(litemkey, litem); litem->prev=NULL; litem->next=list; @@ -258,6 +261,7 @@ void initializethreads() { list=litem; #else //Add our litem to list of threads + mythreadid=0; litem.prev=NULL; litem.next=list; litem.lvector=&lvector; @@ -272,6 +276,8 @@ void initializethreads() { } #if defined(THREADS)||defined(STM) +int threadcounter=0; + void initthread(struct ___Thread___ * ___this___) { #ifdef AFFINITY set_affinity(); @@ -304,6 +310,11 @@ void initthread(struct ___Thread___ * ___this___) { lvector.index=0; litem.prev=NULL; pthread_mutex_lock(&gclistlock); +#ifdef MAC + pthread_setspecific(macthreadid, ++threadcounter); +#else + mythreadid=++threadcounter; +#endif litem.next=list; if(list!=NULL) list->prev=&litem;