Click here to Skip to main content
13,054,779 members (71,507 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi all,

i am new to linux device driver programming, i have one doubt why we don't use wait in interrupt, can any one tell me


[edit]SHOUTING removed - OriginalGriff[/edit]
Posted 13-Apr-13 3:35am
Updated 13-Apr-13 3:36am
OriginalGriff 13-Apr-13 9:36am
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Why do you not wait in an interrupt in a linux device driver? for the same reason you don't wait in any interrupt handler, regardless of OS, processor or task. Because it is a very, very silly thing to do.

Think about it: what is an interrupt?
Answer it is a signal (normally hardware generated) that something has occurred that needs to be dealt with, quickly. Not soon, not when the processor isn't busy, but now. Because if it isn't, data will be lost. And only one interrupt can (normally - there are exceptions) be handled at any one time. If your interrupt handler routine takes too long to run, then other interrupts cannot execute when they need to, or a second event may happen which signals one of your interrupts again while your interrupt is still processing, and then the stack starts to fill up at an alarming rate and the whole system falls over and dies.

Think of an interrupt as a phone ringing: you stop what you are doing, answer the phone have a conversation, and end the call. You then go back to what you were doing before the phone rang. What happens if the doorbell rings while you are on the phone? If you finish your call before you answer the door, the visitor may have left by the time you get there. Or if a second phone rings while you are still dealing with the first? Do you pause the call you are on, and answer the other phone? If so, what happens if the first caller gets bored waiting and tried to ring you back on a third phone? (I'm assuming you have a large desk here, but if not, your personal stack overflows, and your house crashes.)

Keep your interrupt handlers to an absolute minimum. Short, fast, efficient. And get out of them as soon as possible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 13 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100