Btc mtx

Comment

Author: Admin | 2025-04-28

The IPL is no higher than a specified level. See spl(9) for further information on interrupt priority levels (IPLs). mutex_destroy(mtx) Release resources used by a mutex. The mutex may not be used after it has been destroyed. mutex_destroy() may block in order to free memory. mutex_enter(mtx) Acquire a mutex. If the mutex is already held, the caller will block and not return until the mutex is acquired. All loads and stores after mutex_enter() will not be reordered before it or served from a prior cache, and hence will happen after any prior mutex_exit() to release the mutex even on another CPU or in an interrupt. Thus, there is a global total ordering on all loads and stores under the same mutex. Mutexes and other types of locks must always be acquired in a consistent order with respect to each other. Otherwise, the potential for system deadlock exists. Adaptive mutexes and other types of lock that can sleep may not be acquired while a spin mutex is held by the caller. When acquiring a spin mutex, the IPL of the current CPU will be raised to the level set in mutex_init() if it is not already equal or higher. mutex_exit(mtx) Release a mutex. The mutex must have been previously acquired by the caller. Mutexes may be released out of order as needed. All loads and stores before mutex_exit() will not be reordered after it or delayed in a write buffer, and hence will happen before any subsequent mutex_enter() to acquire the mutex even on another CPU or in an interrupt. Thus, there is a global total ordering on all loads and stores under the same mutex. mutex_ownable(mtx) When compiled with LOCKDEBUG ensure that the current process can successfully acquire mtx. If mtx is already owned by the current process, the system will panic with a "locking against myself" error. This function is needed because mutex_owned() does not differentiate if a spin mutex is owned by the current process vs owned by another process. mutex_ownable() is reasonably heavy- weight, and should only be used with KDASSERT(9). mutex_owned(mtx) For adaptive mutexes, return non-zero if the current LWP holds the mutex. For spin mutexes, return non-zero if the mutex is held, potentially by the current processor. Otherwise, return zero. mutex_owned() is provided for making diagnostic checks to verify that a lock is held. For example: KASSERT(mutex_owned(&driver_lock)); It should not be used to make locking decisions at run time. For spin mutexes, it must not be used to verify that a lock is not held. mutex_spin_enter(mtx) Equivalent to mutex_enter(), but may only be used when it is known that mtx is a spin mutex. Implies the same memory ordering as mutex_enter(). On some architectures, this

Add Comment