The role of an interrupt handler is to give feedback to its device about interrupt reception and to read or write data according to the meaning of the interrupt being serviced. The first step usually consists of clearing a bit … Continue reading
A call to read may come when no data is available, but more is expected in the future. Or a process could attempt to write, but your device is not ready to accept the data, because your output buffer is … Continue reading
However, interrupt disabling alone does not always prevent kernel control path interleaving. Indeed, a kernel control path could raise a “Page fault” exception, which in turn could suspend the current process (and thus the corresponding kernel control path). Or again, … Continue reading
For any section of code too large to be defined as an atomic operation, more complicated means of providing critical sections are needed. To ensure that no window is left open for a race condition to slip in, even a … Continue reading
The easiest way to prevent race conditions is by ensuring that an operation is atomic at the chip level: the operation must be executed in a single instruction. These very small atomic operations can be found at the base of … Continue reading
A race condition can occur when the outcome of some computation depends on how two or more interleaved kernel control paths are nested. A critical region is any section of code that should be completely executed by each kernel control … Continue reading
Linux kernel is not preemptive, that is, a running process cannot be preempted (replaced by a higher-priority process) while it remains in Kernel Mode. In particular, the following assertions always hold in Linux: No process running in Kernel Mode may … Continue reading
The CPU and the PCI devices need to access memory that is shared between them. This memory is used by device drivers to control the PCI devices and to pass information between them. Typically the shared memory contains control and … Continue reading
The Serial Peripheral Interface (SPI) bus is a serial master-slave interface similar to I 2C and comes built in on many microcontrollers. It uses four wires (compared to two on I2C): Serial CLocK (SCLK), Chip Select (CS),Master Out Slave In … Continue reading
Kobjects are the mechanism behind the sysfs virtual filesystem. For every directory found in sysfs, there is a kobject lurking somewhere within the kernel. Every kobject of interest also exports one or more attributes, which appear in that kobject’s sysfs … Continue reading
Adding a kobject to a kset is usually done when the object is created; it is a two-step process. The kobject’s kset field must be pointed at the kset of interest; then the kobject should be passed to: int kobject_add(struct … Continue reading
When the i2c core calls the driver’s probe() method signifying the presence of a host adapter, it, in turn,invokes i2c_probe() with arguments specifying the addresses of the slave devices that the driver is responsible for and an associated attach() routine,which … Continue reading
Each class object includes a list of class_device descriptors, each of which represents a single logical device belonging to the class. The class_device structure includes a dev field that points to a device descriptor, thus a logical device always refers … Continue reading
I2C is the name for a two-wire serial bus protocol originally developed by Phillips. It commonly is used in embedded systems so different components can communicate; PC motherboards use I2C to talk to different sensor chips. Those sensors typically report … Continue reading
VFS considers each directory a file that contains a list of files and other directories.Once a directory entry is read into memory, however, it is transformed by the VFS into a dentry object based on the dentry structure.The kernel creates … Continue reading