void *loopWithGoto (void *lis) { list *nod; nod = lis; while (nod && (((dl*)nod->obj)->x != 10 )) { // racy read.. nod = nod->next; } _spin_lock (((dl*)nod->obj)->l); if(((dl*)nod->obj)->x >= MAX) { _spin_unlock (((dl*)nod->obj)->l); goto _end; } ((dl*)nod->obj)->x = ((dl*)nod->obj)->x + 1; _spin_unlock (((dl*)nod->obj)->l); _end: return 0; }
int main(int argc, char *argv[]) { int x = 10; int y = 11; deposit1(10); deposit2(11); transfer(100); safeDeposit(&gLock2, 2, 1337); condDeposit1(1, 10); _spin_lock(&gLock1); foo(); _spin_lock(&gLock2); glob2++; lockedOnEntry(); _spin_unlock(&gLock1); if(y < x) goto label1; x++; y++; munge(&V1,&gLockV1); munge(&V2,&gLockV2); munge(&V3,&gLockV3); recurses(&V1,&gLockV1); multi_recurses1(&gLockV4); label0: y++; return 0; label1: x++; return 1; }
void loop(list *list) { while (list) { _spin_lock (((dl*)(list->obj))->l); (((dl*)(list->obj))->x) = (((dl*)(list->obj))->x) + 1; _spin_unlock (((dl*)(list->obj))->l); list = list->next; } }
unsigned long _spin_lock_irqsave(spinlock_t *lock) { unsigned long flags; local_irq_save(flags); _spin_lock(lock); return flags; }
void recurses(int *x, spinlock_t *l){ _spin_lock(l); *x--; _spin_unlock(l); if(*x > 0) { recurses(x, l); } }
void multi_recurses4(spinlock_t *l){ _spin_lock(l); bar(); _spin_unlock(l); if(glob2 > 0) { multi_recurses1(l); } }
void multi_recurses5(spinlock_t *l1, spinlock_t *l2){ _spin_lock(l2); bar(); _spin_unlock(l2); if(glob2 > 0) { multi_recurses5(l2,l1); } }
static void module_activity() { struct net_device *dev; _spin_lock(®istration_lock); /* If you uncomment the next line and comment out the call to plip_attach (i.e., you inline plip_attach), then the race at dummydev->irq = 5 is detected */ // dummydev = (struct net_device *) malloc(sizeof(struct net_device)); plip_attach(); _spin_unlock(®istration_lock); dummydev->irq = 5; }
void *munge (void *mArg) { dl *dl = (dl*) mArg; _spin_lock (dl->l); dl->x = dl->x + 1; _spin_unlock (dl->l); return 0; }
void racyGetterUse(list *l) { dl *curObj; spinlock_t *tempLock; curObj = getObj (l); tempLock = getLock (curObj); _spin_lock (tempLock); curObj->x = curObj->x + 13; _spin_unlock (tempLock); }
void *lockWithGoto(void *obj) { dl *data_lock = (dl*) obj; _spin_lock (data_lock->l); if(data_lock->x >= MAX) { _spin_unlock (data_lock->l); goto _end; } data_lock->x = data_lock->x + 1; _spin_unlock (data_lock->l); _end: return 0; }
void *mungeMax (void *mmArg) { dl *data_lock = (dl*) mmArg; _spin_lock (data_lock->l); if(data_lock->x >= MAX) { _spin_unlock (data_lock->l); return 0; } data_lock->x = data_lock->x + 1; _spin_unlock (data_lock->l); return 0; }
/* conditionally safe deposit */ void condDeposit1(int cond, int a) { int junk = 0; if(cond) { _spin_lock(&gLock1); printf("Condition is true\n"); donor1_blood += a; srand(junk); } junk++; if(cond) { _spin_unlock(&gLock1); junk--; srand(junk); } }
int func (void) { int mylock = 1; int mylock2 = 1; int mylock3 = 1; if (!_spin_trylock(mylock)) { return; } _spin_unlock(mylock); _spin_unlock(mylock2); if (a) _spin_unlock(mylock); _spin_lock(mylock2); if (!_spin_trylock(mylock3)) return; return; }
inline bool Acquire() { _spin_lock(&m1); return true; }
void _spin_lock_irq(spinlock_t *lock) { ASSERT(local_irq_is_enabled()); local_irq_disable(); _spin_lock(lock); }
void munge2(int *x, spinlock_t *l){ _spin_lock(l); *x++; _spin_unlock(l); }
static void module_activity() { _spin_lock(®istration_lock); x = 3; _spin_unlock(®istration_lock); }
void noCheckDep1(int a) { _spin_lock(&gLock1); donor1_blood += a; _spin_unlock(&gLock1); }