LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   kernel programming related(timers,interrupts,etc) (https://www.linuxquestions.org/questions/programming-9/kernel-programming-related-timers-interrupts-etc-701776/)

sritejv 02-02-2009 08:13 PM

kernel programming related(timers,interrupts,etc)
 
Hi guys,

I am relatively new to linux kernel programming and i have a few questions related to kernel programming

1)init_timer().when we initalize a timer we set the timeout period and the function to be called when the timeout occurs.

how is the timeout event brought to notice?Software interrupt perhaps?whatever maybe the case,the function that was initialized gets executed.

I used this timeout function in a driver code.This timeout function shares a resource with an interrupt handler and a tasklet.So I want to know the priority this timeout function has so that i can implement a suitable synchronization mechanism.

2)are interrupts handler routines allowed to run from begin to end without interruption or some of them can be interrupted to handle higher priority interrupts?

3) the function void spin_lock_irqsave(spinlock_t *lock,unsigned long flags) disables the interrupts on the machine and stores the flag register state.
how do i pass the flag register?i dont have access to flags in my code.

any help is highly appreciated,
thanks,
tej

sundialsvcs 02-03-2009 10:04 AM

On any modern computer, interrupts do have a priority, imposed upon them by a chip such as the APIC. This equipment allows multiple devices to share an interrupt-line, and it allows interrupts to be prioritized.

The "first level" interrupt handler should do the minimum amount of work needed to capture the status of the interrupting device (and to quiesce the interrupt). It may assume that it will not be interrupted by an interrupt of equal-or-lower priority; nothing more.

In a multi-CPU system, however, another CPU may well be manipulating that same data structure!

The "second level" interrupt response ... and this includes anything that involves waiting and so-forth ... should be presumed to happen "soon, but not immediately."

Categorically, do not make any assumptions about the order in which things may occur, nor what kind of wall-clock time delays might be experienced. You are obligated to write code that works correctly: "no matter what, and no matter when."

The kernel source-tree is filled with copious example of "code that works." Study it and copy it, without shame.


All times are GMT -5. The time now is 02:26 AM.