ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.