Lines Matching refs:lock
43 Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)
45 lock->lock = 0;
46 lock->cpu = 0;
47 lock->count = 0;
48 lock->rCount = 0;
49 lock->lockTime = 0;
50 lock->waitTime = 0;
51 lock->type = type;
53 strncpy(&lock->name[0], name, SPINLOCK_NAMELEN);
56 LIST_INSERT_HEAD(&lockList, lock, lockList);
61 Spinlock_Destroy(Spinlock *lock)
64 LIST_REMOVE(lock, lockList);
75 Spinlock_Lock(Spinlock *lock) __NO_LOCK_ANALYSIS
81 while (atomic_swap_uint64(&lock->lock, 1) == 1)
83 if (lock->type == SPINLOCK_TYPE_RECURSIVE && lock->cpu == CPU()) {
87 kprintf("Spinlock_Lock(%s): waiting for over a second!\n", lock->name);
91 lock->waitTime += Time_GetTSC() - startTSC;
93 lock->cpu = CPU();
94 lock->count++;
96 lock->rCount++;
97 if (lock->rCount == 1)
98 lock->lockedTSC = Time_GetTSC();
100 TAILQ_INSERT_TAIL(&lockStack[CPU()], lock, lockStack);
109 Spinlock_Unlock(Spinlock *lock) __NO_LOCK_ANALYSIS
111 ASSERT(lock->cpu == CPU());
113 TAILQ_REMOVE(&lockStack[CPU()], lock, lockStack);
115 lock->rCount--;
116 if (lock->rCount == 0) {
117 lock->cpu = 0;
118 lock->lockTime += Time_GetTSC() - lock->lockedTSC;
119 atomic_set_uint64(&lock->lock, 0);
126 Spinlock_IsHeld(Spinlock *lock)
128 return (lock->cpu == CPU()) && (lock->lock == 1);
134 Spinlock *lock;
139 LIST_FOREACH(lock, &lockList, lockList)
141 kprintf("%-36s %6llu %3llu %8llu %12llu %12llu\n", lock->name,
142 lock->lock, lock->cpu, lock->count,
143 lock->waitTime, lock->lockTime);
155 Spinlock *lock;
158 TAILQ_FOREACH(lock, &lockStack[c], lockStack) {
159 kprintf(" %s\n", lock->name);