From: bdemsky Date: Thu, 14 Apr 2011 06:51:33 +0000 (+0000) Subject: changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eb44de8f9b06c8224f0f6b21088536b0f4b910ab;p=IRC.git changes --- diff --git a/Robust/src/Runtime/affinity.c b/Robust/src/Runtime/affinity.c index 8ea239d3..d2c71145 100644 --- a/Robust/src/Runtime/affinity.c +++ b/Robust/src/Runtime/affinity.c @@ -7,27 +7,17 @@ #include #include #include +#include "mlp_lock.h" static volatile unsigned int corecount=0; - -static inline int atomicinc(volatile unsigned int *lock) { - int retval=1; - __asm__ __volatile__("lock; xadd %0,%1" - : "=r"(retval) - : "m"(*lock), "0"(retval) - : "memory"); - return retval; -} - - void set_affinity() { int err; cpu_set_t cpumask; CPU_ZERO(&cpumask); - int ourcount=atomicinc(&corecount); + int ourcount=atomicincandread(&corecount); ourcount=ourcount&7; int newvalue=ourcount>>1; if (ourcount&1) { diff --git a/Robust/src/Runtime/mlp_lock.h b/Robust/src/Runtime/mlp_lock.h index d99a3270..ad33a424 100644 --- a/Robust/src/Runtime/mlp_lock.h +++ b/Robust/src/Runtime/mlp_lock.h @@ -21,6 +21,15 @@ "661:\n\tlock; " +static inline int atomicincandread(volatile unsigned int *lock) { + int retval=1; + __asm__ __volatile__("lock; xadd %0,%1" + : "=r"(retval) + : "m"(*lock), "0"(retval) + : "memory"); + return retval; +} + static inline void atomic_dec(volatile int *v) { __asm__ __volatile__ (LOCK_PREFIX "decl %0" : "+m" (*v));