- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Linux 新手,正在阅读 Rubini & Corbet 所著的 Linux 设备驱动程序。我对与 spinlocks
相关的一项声明感到困惑;这本书说
If a nonpreemptive uniprocessor system ever went into a spin on a lock, it would spin forever; no other thread would ever be able to obtain the CPU to release the lock. For this reason, spinlock operations on uniprocessor systems without preemption enabled are optimized to do nothing, with the exception of the ones that change the IRQ masking status.
The kernel preemption case is handled by the spinlock code itself. Any time kernel code holds a spinlock, preemption is disabled on the relevant processor. Even uniprocessor systems must disable preemption in this way to avoid race conditions.
最佳答案
你的第一个问题的答案是你的第二个问题背后的推理。
内核获取的自旋锁可以通过关闭抢占来实现,因为这可以确保内核将在没有其他进程干扰的情况下完成其临界区。重点是在内核释放锁之前,另一个进程将无法运行。
没有理由必须以这种方式实现;这只是一种实现它的简单方法,可以防止任何进程在内核持有的锁上旋转。但是这个技巧只适用于内核已经获得锁的情况:用户进程不能关闭抢占,如果内核正在旋转(即它试图获取一个自旋锁但另一个进程已经拥有它)它最好离开抢占上!否则系统将挂起,因为内核正在等待一个不会被释放的锁,因为持有它的进程无法释放它。
内核获取自旋锁是一种特殊情况。如果用户级程序获得了自旋锁,则不会禁用抢占。
关于kernel - 为什么linux在内核代码持有自旋锁后禁用内核抢占?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18254713/
我写了一段代码,其中有一个数据: unsigned char buf[4096]; // data in chunks of size 4k unsigned counter[256]; 我将每 3
这个问题已经有答案了: Ajax too slow - Recursion (1 个回答) 已关闭 5 年前。 所以这件事在我脑海里思考了很长时间,是否 AJAx 中给出的计时器在它必须发送另一个请求
据我所知,在 Linux 中有许多机制可以实现 bottom-halves: 软中断 任务 工作队列 线程中断 ( request_threaded_irq() ) 它们在可调度性方面都有自己的特点。
根据这个问题here使用 pthread_spin_lock 锁定关键部分是危险的,因为线程可能会被调度程序中断,而其他线程可能会在该资源上保持旋转状态。 假设我决定从 pthread_spin_lo
从SLF4J页面我明白了这一点 The purpose of slf4j-log4j12 module is to delegate or redirect calls made to an SLF4
我在我的项目中使用了 xuggle library 将视频从 mp4 转码为 flv。我也使用 slf4j 库 来支持日志结束。 import com.xuggle.mediatool.IMediaR
我是一名优秀的程序员,十分优秀!