Lines Matching refs:mutex
27 static int fastmutex_create(const char *name, fastmutex_t * mutex);
28 static int fastmutex_destroy(fastmutex_t * mutex);
29 static int fastmutex_lock(fastmutex_t * mutex);
30 static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout);
31 static int fastmutex_unlock(fastmutex_t * mutex);
34 static int fastmutex_create(const char *name, fastmutex_t * mutex) in fastmutex_create() argument
36 mutex->count = 0; in fastmutex_create()
37 mutex->sem = create_semaphore(name, 0, 0); in fastmutex_create()
38 return (mutex->sem < 0) ? -1 : 0; in fastmutex_create()
42 static int fastmutex_destroy(fastmutex_t * mutex) in fastmutex_destroy() argument
44 if (fastmutex_timedlock(mutex, 0) == 0 || errno == EWOULDBLOCK) { in fastmutex_destroy()
45 return delete_semaphore(mutex->sem); in fastmutex_destroy()
51 static int fastmutex_lock(fastmutex_t * mutex) in fastmutex_lock() argument
53 atomic_t prev = atomic_add(&mutex->count, 1); in fastmutex_lock()
55 return lock_semaphore(mutex->sem); in fastmutex_lock()
60 static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout) in fastmutex_timedlock() argument
62 atomic_t prev = atomic_add(&mutex->count, 1); in fastmutex_timedlock()
64 return lock_semaphore_x(mutex->sem, 1, 0, timeout); in fastmutex_timedlock()
69 static int fastmutex_unlock(fastmutex_t * mutex) in fastmutex_unlock() argument
71 atomic_t prev = atomic_add(&mutex->count, -1); in fastmutex_unlock()
73 return unlock_semaphore(mutex->sem); in fastmutex_unlock()