From: adash Date: Mon, 20 Apr 2009 23:30:35 +0000 (+0000) Subject: Add runtime support for STM Barrier class X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=699712f7ed04e446729d5f95d6ffe880fc4d8b6f;p=IRC.git Add runtime support for STM Barrier class --- diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 1a2fc920..057ccb82 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -14,6 +14,10 @@ #endif #ifdef STM #include "tm.h" +#include +/* Global barrier for STM */ +pthread_barrier_t barrier; +pthread_barrierattr_t attr; #endif #include @@ -180,6 +184,36 @@ void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Objec #endif +#ifdef STM +/* STM Barrier constructs */ +void CALL11(___Barrier______setBarrier____I, int nthreads, int nthreads) { +#ifdef PRECISE_GC + struct listitem *tmp=stopforgc((struct garbagelist *)___params___); +#endif + // Barrier initialization + int ret; + if((ret = pthread_barrier_init(&barrier, NULL, nthreads)) != 0) { + printf("%s() Could not create a barrier: error %d\n", __func__, errno); + perror(""); + exit(-1); + } +#ifdef PRECISE_GC + restartaftergc(tmp); +#endif +} + +void CALL00(___Barrier______enterBarrier____) { + // Synchronization point + int ret; + ret = pthread_barrier_wait(&barrier); + if(ret != 0) { + printf("%s() Could not wait on barrier: error %d\n", __func__, errno); + perror(""); + exit(-1); + } +} +#endif + /* Object allocation function */ #ifdef DSTM