system
Given the following post, respond as if you're commenting on Reddit:
human
Need help understanding Interupts

Hey guys, i'm currently reading up on this semesters curriculum, and i'm kind of stuck on what Interrupts do. I have to answer a question asking what they are, and how hardware and the OS software work together when an interrupt occurs.

I just need a very very basic understanding of this subject.

So far what i've gathered is:

Interrupts are signals sent to the CPU, saying there is something wrong that it needs to take care of immidiately.

There is a hardware interrupt: Generated by hardware devices, usually I/O devices like a mouse click or a button pressed on the keyboard that the OS handles within milliseconds, or that it has completed a task like transferring data etc.

Software interrupts is when a program requests some type of handling, that an error has occured and it needs fixing. Here the current CPU task is put on hold, and "saved" or maintained. The CPU changes into a "interrupt handler routine" and executes some code from the OS to fix said problem, and then continues where it left off when done.

Is this correct? Now i'm confused about the question how the hardware and software work together when an interrupt occurs.

As i said i need a veery basic understanding, so if i'm missing some small details its no problem.

Hope you can help, thanks!
gpt
\> Interrupts are signals sent to the CPU, saying there is something wrong  

Something HAPPENED, not something is WRONG necessarily.

\> an error has occurred and it needs fixing 

Sometimes it's as simple as "there is data we are now ready for you to read."

Behind the scenes, your operating system is taking ALL your registers, pushing them onto the stack, then calling your interrupt routine. This is why, in C, your interrupt handler cannot really take any parameters. The caller has no idea about the layout of your program, and the handler has to have  a very strict signature.