Categories
Linux Tutorial Series

Linux Tutorial Series – 109.1 – Difference between signals and interrupts

The question you may have is: “What is the difference between signals and interrupts?

The difference is as follows: Interrupts are the communication between the CPU (Central Processing Unit – your processor) and the operating system (the kernel), and signals are the communication between processes and the operating system (the kernel). (“Signals and interrupts a comparison,” n.d.)⁠

Let’s go into a bit more depth:

When an interrupt occurs (initiated by either hardware or software) it is actually managed by the CPU itself, which “interrupts” (pauses) the execution of the current process and tells the kernel to invoke the interrupt signal handler (which, to recap, is a program designed to handle interrupts). Signals, on the other hand, are used to communicate between processes. But, when the signal is traveling from the sending process to the receiving process, it is managed by the kernel, which invokes the action appropriate for the signal the process received.

I hope you gained some clarity on the difference between the two. This isn’t so that important and honestly I could have left out the part with the interrupts, but I just wanted for you to know about them since we were already talking about the operating system at such a low level. If you didn’t quite catch it, don’t worry – it won’t be that much of a hinderance.

Hope you learned something useful!

References

Signals and interrupts a comparison. (n.d.). Retrieved February 14, 2020, from https://stackoverflow.com/questions/13341870/signals-and-interrupts-a-comparison

Categories
Linux Tutorial Series

Linux Tutorial Series – 109 – Hardware and software interrupts

Here is the video version, if you prefer it:

This is for the curious souls out there. I hope there are some. Even if you are not as curious, you will benefit from reading this as it paints the bigger picture.

You may have pondered something along the lines of: “OK, there exist processes. OK, processes have priorities. But what is the connection between hardware and software? That is, how does the operating system know that we, for example, moved our mouse? Are we dealing with signals?” Not quite, but the concept is very similar.

Here is where the concept of hardware and software interrupts comes in. Basically, hardware and software interrupts tell the operating system (the kernel): “Hey, deal with me!”. For example, pressing a key on your keyboard triggers a hardware interrupt and your operating system processes it. Interrupts also have priorities, because multiple interrupts can occur at the same time and they need to be handled according to their urgency. It is also important to note that there are programs called interrupt handlers that are executed when an interrupt occurs.

An important caveat: This is not exactly how it works, but it paints the picture. In the next post, I will clarify the details, but they are minor and don’t impact your understanding that much.

Hope you learned something new!