void multi_recurses4(spinlock_t *l){ _spin_lock(l); bar(); _spin_unlock(l); if(glob2 > 0) { multi_recurses1(l); } }
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; }
void *munge (void *mArg) { dl *dl = (dl*) mArg; _spin_lock (dl->l); dl->x = dl->x + 1; _spin_unlock (dl->l); return 0; }
int transfer(int a) { int res; int succ = 0; res = _spin_trylock(&gLock1); if(res == 0) { res = _spin_trylock(&gLock2); if(res == 0) { if(donor1_blood >= a) { donor1_blood -= a; donor2_blood += a; succ = 1; } _spin_unlock(&gLock2); } _spin_unlock(&gLock1); } return succ; }
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 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); }
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; }
/* 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 safeDeposit(spinlock_t *l, int dnum, int a) { int res; int succ = 0; res = _spin_trylock(l); if(res == 0) { switch (dnum) { case 1: donor1_blood += a; break; case 2: donor2_blood += a; break; } succ = 1; } if(res == 0) { donor1_blood += 1; _spin_unlock(l); } return succ; }
inline bool Release() { _spin_unlock(&m1); return true; }
void noCheckDep1(int a) { _spin_lock(&gLock1); donor1_blood += a; _spin_unlock(&gLock1); }
void munge2(int *x, spinlock_t *l){ _spin_lock(l); *x++; _spin_unlock(l); }
int lockedOnEntry() { _spin_unlock(&gLock2); glob++; return glob; }
void _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { _spin_unlock(lock); local_irq_restore(flags); }
void _spin_unlock_irq(spinlock_t *lock) { _spin_unlock(lock); local_irq_enable(); }
static void module_activity() { _spin_lock(®istration_lock); x = 3; _spin_unlock(®istration_lock); }