-2

I read in an operating system book I'm using that interrupt handling may have some side effects on the running process but there were no more details about it. I thought about blocking all interrupts when a program is running. Can somenone tell me if I'm right? are there any other side effects that I'm ignoring using that solution?

user3045065
  • 23
  • 1
  • 6

1 Answers1

3

An interrupt is a direct line to the CPU which tells the CPU to stop everything it is doing and run a function called interrupt handler. An interrupt is only temporarily and when is finished all the applications resume their work.

Interrupts should never be blocked because they are essential.

There are both hardware and software interrupts.

For example whenever you press a key on the keyboard an interrupt is called so the CPU and eventually the OS would know that the user wants to interact.

Another example (in rare situations where you don't have DMA) is when data is coming in the network card, the CPU has to stop for a fraction of a time to accept the data.

Software interrupts are handled mostly in the operating system and they are essential for handling various important things such as multitasking or unrecoverable errors.

Interrupts are a tricky thing to balance because they are required for low latency operations and if you abuse them you may notice severe performance degradation.

Unless you don't absolutely need them for achieving real-time operation it is strongly advisable not to touch them.

Bogdan
  • 622
  • 6
  • 21
  • "Interrupts are a tricky thing to balance because they are required for low latency operations and if you abuse them you may notice severe performance degradation." can you explain to me what did you mean by that? – user3045065 Mar 08 '15 at 10:21
  • In extreme conditions, if you are interrupting the system all the time with some event then it might not get the chance to do other things which are also necessary because the system spends all the time processing interrupts. For **very** basic CPUs you could saturate all the CPU by pressing a key on the keyboard or by sending a lot of network traffic. [HLK-RM04](http://www.hlktech.net/product_detail.php?ProId=39) is a good example of a board where the CPU could easily be saturated by a lot of network traffic. – Bogdan Mar 08 '15 at 10:28
  • Thank you very much. BTW, I just read that there is a side effect while interrupt handling which related to the situation when two programs try to write to the same file, and there was an interrupt in the middle of one of them. What is the problem with that? – user3045065 Mar 08 '15 at 10:45
  • You're welcome. I doubt this is a generic problem of interrupt handling. – Bogdan Mar 08 '15 at 10:49
  • Yeah - it's more of a misunderstanding of how preemptive OS works and the essential role played by interrupts. – Martin James Mar 08 '15 at 11:47