Lines Matching refs:lock

10 void mutex_init(mutex_t *lock)  in mutex_init()  argument
12 atomic_set(&lock->count, 1); in mutex_init()
13 spin_init(&lock->wait_lock); in mutex_init()
14 list_init(&lock->wait_list); in mutex_init()
23 static void __mutex_acquire(mutex_t *lock) in __mutex_acquire() argument
31 void mutex_lock(mutex_t *lock) in mutex_lock() argument
37 spin_lock(&lock->wait_lock); in mutex_lock()
38 if (likely(mutex_is_locked(lock))) in mutex_lock()
44 spin_unlock(&lock->wait_lock); in mutex_lock()
50 list_append(&lock->wait_list, &waiter->list); in mutex_lock()
52 spin_unlock(&lock->wait_lock); in mutex_lock()
58 atomic_dec(&lock->count); in mutex_lock()
59 spin_unlock(&lock->wait_lock); in mutex_lock()
70 void mutex_unlock(mutex_t *lock) in mutex_unlock() argument
72 if (unlikely(!mutex_is_locked(lock))) in mutex_unlock()
75 spin_lock(&lock->wait_lock); in mutex_unlock()
77 if (mutex_is_locked(lock)) in mutex_unlock()
79 if (!list_empty(&lock->wait_list)) in mutex_unlock()
80 wt = container_of(list_next(&lock->wait_list), struct mutex_waiter_t, list); in mutex_unlock()
82 atomic_inc(&lock->count); in mutex_unlock()
87 spin_unlock(&lock->wait_lock); in mutex_unlock()
103 int mutex_trylock(mutex_t *lock) in mutex_trylock() argument
105 if (mutex_is_locked(lock)) in mutex_trylock()
108 spin_lock(&lock->wait_lock); in mutex_trylock()
109 if (mutex_is_locked(lock)) in mutex_trylock()
111 spin_unlock(&lock->wait_lock); in mutex_trylock()
116 atomic_dec(&lock->count); in mutex_trylock()
117 spin_unlock(&lock->wait_lock); in mutex_trylock()