Click here to Skip to main content
15,942,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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]
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

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.
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900