/* SPDX-License-Identifier: GPL-2.0 */ /* * Mutexes: blocking mutual exclusion locks * * started by Ingo Molnar: * * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> * * This file contains the main data structure and API definitions.
*/ #ifndef __LINUX_MUTEX_H #define __LINUX_MUTEX_H
/** * mutex_init - initialize the mutex * @mutex: the mutex to be initialized * * Initialize the mutex to unlocked state. * * It is not allowed to initialize an already locked mutex.
*/ #define mutex_init(mutex) \ do { \ staticstruct lock_class_key __key; \
\
__mutex_init((mutex), #mutex, &__key); \
} while (0)
/** * mutex_init_with_key - initialize a mutex with a given lockdep key * @mutex: the mutex to be initialized * @key: the lockdep key to be associated with the mutex * * Initialize the mutex to the unlocked state. * * It is not allowed to initialize an already locked mutex.
*/ #define mutex_init_with_key(mutex, key) __mutex_init((mutex), #mutex, (key))
/** * mutex_is_locked - is the mutex locked * @lock: the mutex to be queried * * Returns true if the mutex is locked, false if unlocked.
*/ externbool mutex_is_locked(struct mutex *lock);
#else/* !CONFIG_PREEMPT_RT */ /* * Preempt-RT variant based on rtmutexes.
*/
#define __mutex_init(mutex, name, key) \ do { \
rt_mutex_base_init(&(mutex)->rtmutex); \
__mutex_rt_init((mutex), name, key); \
} while (0)
#endif/* CONFIG_PREEMPT_RT */
#ifdef CONFIG_DEBUG_MUTEXES
int __must_check __devm_mutex_init(struct device *dev, struct mutex *lock);
#else
staticinlineint __must_check __devm_mutex_init(struct device *dev, struct mutex *lock)
{ /* * When CONFIG_DEBUG_MUTEXES is off mutex_destroy() is just a nop so * no really need to register it in the devm subsystem.
*/ return 0;
}
/* * NOTE: mutex_trylock() follows the spin_trylock() convention, * not the down_trylock() convention! * * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.