- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道为什么我们可以在中断上下文中使用信号量 up() 而互斥量的相同变体,即 mutex_unlock() 不能在中断上下文中使用。以下是内核的片段
/**
* mutex_unlock - release the mutex
* @lock: the mutex to be released
*
* Unlock a mutex that has been locked by this task previously.
*
* This function must not be used in interrupt context. Unlocking
* of a not locked mutex is not allowed.
*
* This function is similar to (but not equivalent to) up().
*/
void __sched mutex_unlock(struct mutex *lock)
{
#ifndef CONFIG_DEBUG_LOCK_ALLOC
if (__mutex_unlock_fast(lock))
return;
#endif
__mutex_unlock_slowpath(lock, _RET_IP_);
}EXPORT_SYMBOL(mutex_unlock);
/**
* up - release the semaphore
* @sem: the semaphore to release
*
* Release the semaphore. Unlike mutexes, up() may be called from any
* context and even by tasks which have never called down().
*/
void up(struct semaphore *sem)
{
unsigned long flags;
raw_spin_lock_irqsave(&sem->lock, flags);
if (likely(list_empty(&sem->wait_list)))
sem->count++;
else
__up(sem);
raw_spin_unlock_irqrestore(&sem->lock, flags);
}
EXPORT_SYMBOL(up);
最佳答案
mutex_unlock
需要一个 mutex-internal spinlock in a non-irq-safefashion - 例如如果设置了 CONFIG_PREEMPT_RT
,raw_spin_lock
可能会休眠 - 因此,如果时机正确,IRQ 上下文中的 mutex_unlock
将死锁。
关于linux-kernel - 关于 linux 内核中的信号量 up() 和 mutex_unlock(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48703000/
代码: void *inc_func(void *arg) { pthread_mutex_lock(&mutex); pthread_cond_signal(&count_thres
我将描述的情况发生在 iPad 4 (ARMv7s) 上,使用 posix 库进行互斥锁定/解锁。不过,我在其他 ARMv7 设备上看到过类似的情况(见下文),所以我认为任何解决方案都需要更全面地了解
我有两个线程 - threadA 和 threadB。如果 B 正在等待 A 拥有的互斥量,假设它的优先级高于 A,它会在 A 解锁后立即获得所有权吗? 这不是关于当多个线程正在等待时谁获得锁的问题,
我想知道为什么我们可以在中断上下文中使用信号量 up() 而互斥量的相同变体,即 mutex_unlock() 不能在中断上下文中使用。以下是内核的片段 /** * mutex_unlock - re
我是一名优秀的程序员,十分优秀!