RTAI與LINUX關於中斷共享分析

2021-05-04 13:08:25 字數 1474 閱讀 8175

1.

linux2.6

中斷資料結構:

extern struct irq_descirq_desc[nr_irqs]; //

中斷描述符表

structirqaction;

在中斷初始化階段,呼叫hw_interrupt_type 型別的變數初始化irq_desc_t 結構中的handle 成員。在早期的系統中使用級聯的8259a,所以將用i8259a_irq_type 來進行初始化,而對於smp系統來說,要麼以ioapic_edge_type,或以ioapic_level_type 來初始化handle 變數。

對於每乙個外設,要麼以靜態(宣告為static 型別的全域性變數)或動態(呼叫request_irq 函式)的方式向linux 核心註冊中斷處理程式。不管以何種方式註冊,都會宣告或分配一塊irqaction 結構(其中handler 指向中斷服務程式),然後呼叫setup_irq() 函式,將irq_desc_t 和irqaction 聯絡起來。

中斷註冊函式:

request_irq - allocate an interrupt line

*@irq: interrupt line to allocate

*@handler: function to be called when the irq occurs

*@irqflags: interrupt type flags

*@devname: an ascii name for the claiming device

*@dev_id: a cookie passed back to the handler function

*flags:irqf_sharedinterrupt is shared

intrequest_irq(unsigned int irq, irq_handler_t handler,

unsigned long irqflags, const char *devname, void *dev_id) (

具體中斷共享機制參考《linux如何處理共享中斷》) 2.

rtai3.5

中斷資料結構

struct rtai_realtime_irq_srtai_realtime_irq;

structrtai_realtime_irq_s;

中斷註冊請求函式:

int rt_request_irq(unsigned irq, rt_irq_handler_t handler, void *cookie, int retmode)

每個irq只能註冊乙個handler,因而不支援中斷共享。分析原因:rtai為了保證中斷的實時性,因而避免了終端共享機制中對irq中斷鏈上每個註冊中斷函式的遍歷處理。

LINUX中斷機制與訊號

在學習apue時學習訊號程式設計,很多地方不是理解,便查閱了網路上的相關資料,最常見的一句話就是 訊號是中斷機制的一種模擬 既然提到了中斷,那就首先了解了一下中斷的具體分類以及實現,最後再找出中斷和訊號的區別。l 中 斷 也稱硬體中斷 定義 中斷是由其他硬體裝置依照cpu 時鐘週期訊號隨機產生的。分...

linux軟中斷與tasklet

軟中斷軟中斷由 struct softirq action void action struct softirq action 表示。並且當前核心中的軟中斷總數固定為32個,由陣列static struct softirq actionsoftirq vec nr softirqs 來表示。目前只用...

linux中斷與系統呼叫

1.系統使用巨集syscallx 將相應的系統呼叫定義為其同名函式。呼叫中斷int 0x80.並將引數傳送到相應的暫存器中,供entry system call 使用。2.進入entry system call 中,當系統呼叫合法時,根據索引值,在sys call table中找到相應的實際服務程式...