Linux Kernel development (3)

Kernel Data Structures

The linked-list code is declared in the header file and the data structure is simple:
Usage is slightly different in kernel versions prior to 2.6.33—doublecheck before writing code
rbtrees The Linux implementation of red-black trees is called rbtrees.They are defined in lib/rbtree.c

Interrupts and Interrupt Handlers

Interrupt Handlers
The interrupt handler for a device is part of the device’s driver—the kernel code that manages the device.
Top Halves Versus Bottom Halves
These two goals—that an interrupt handler execute quickly and perform a large amount of work—clearly conflict with _disibledevent=>imageLinux Kernel development (3)
unsigned int do_IRQ(struct pt_regs regs)
kernel/irq/handler.c
/proc/interrupts
Interrupt Control
Because Linux supports multiple processors, kernel code more generally needs to obtain some sort of lock to prevent another processor from accessing shared data simultaneously.These locks are often obtained in conjunction with disabling local interrupts.
Disabling and Enabling Interrupts
local_irq_disable();
/* interrupts are disabled .. */
local_irq_enable();
In other words, they disable and enable interrupt delivery on the issuing processor.
Disabling a Specific Interrupt Line
All three of these functions can be called from interrupt or process context and do not sleep. If calling from interrupt context, be careful! You do not want, for example, to enable an interrupt line while you are handling it. (Recall that the interrupt line of a handler is masked out while it is serviced.)
Status of the Interrupt System
in_interrupt()
in_irq()
The most useful is the first: It returns nonzero if the kernel is performing any type of interrupt handling.This includes either executing an interrupt handler or a bottom half handler.The macro in_irq() returns nonzero only if the kernel is specifically executing an interrupt handler.
Tags: 

延伸阅读

最新评论

发表评论