(转)Memory barrier

程序在运行时,内存实际的访问顺序和程序代码编写的访问顺序不一定一致,基于这个前提,Memory barrier 就有存在的必要了。

Memory barrier 能够保证其之前的内存访问操作先于其后的完成。Memory barrier的主要应用场景如下:

  1. 实现同步原语(synchronization primitives)
  2. 实现无锁数据结构(lock-free data structures)
  3. 驱动程序

Understanding the Linux Kernel 读书笔记-Block Device Drivers

We start in the first section “Block Devices Handling” to explain the general architecture of the Linux block I/O subsystem. In the sections “The Generic Block Layer,” “The I/O Scheduler,” and “Block Device Drivers,” we will describe the main components of the block I/O subsystem. Finally, in the last section, “Opening a Block Device File,” we will outline the steps performed by the kernel when opening a block device file.