LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2009, 08:13 PM   #1
sritejv
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
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
 
Old 02-03-2009, 10:04 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Timers of ARM in Kernel? raedbenz Linux - Embedded & Single-board computer 2 06-30-2008 04:15 AM
LXer: Linux: High-Res Timers and Tickless Kernel LXer Syndicated Linux News 0 06-24-2006 07:21 AM
How to build kernel timers? santhosh.linux Programming 1 12-14-2005 09:10 PM
Programming Timers (creation, setting)in FC3 juan_de_margo Fedora 1 02-14-2005 11:34 PM
kernel-level timers? for benchmarking... microtim Programming 1 03-10-2003 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration