0

It might be a stupid question where the answer is "no" but is that theoretically possible ? I wonder why not ?

And I don't know what for...

2
  • 1
    In what context? A certain programming language / problem?
    – Joe Sewell
    Commented Oct 21, 2019 at 15:50
  • It's more a general question but you can consider C, programming an OS or whatever
    – Welgriv
    Commented Oct 21, 2019 at 15:53

1 Answer 1

2

There's several different types of "interrupt handlers".

The first, the hardware IRQ handlers, are modified when the OS loads drivers and such.

The second, the software interrupt handlers, are used to call OS level services in modern OSes.

Those are the ones that have hardware support (either across the entire computer, or within the processor).

A third kind, without hardware support, are "signal handlers" (in UNIX), which are basically OS-level and relate to OS events.

The common concept between them is that the responses are programmable. The idea is that you know how you want your software/OS to respond to them, so you add the code necessary to service them. In that sense, they are "modifiable at runtime".

But there are rules as to what to do in these things. Primarily, you don't want to waste too much time handling them, because whatever you do with them prevents other interrupts (of the same or lower priority) from occurring while you're processing them. (For example, you don't want to be in the middle of handling one interrupt and get another interrupt for the same thing before you finish handling the first one, because an interrupt handler can do things that would otherwise require a lock (loading and incrementing the current or last pointers on a ring queue, for example) and would clobber the state if it re-entered.)

So, typically interrupt handlers do the least of what they need to do, and set a flag for the software to recognize that processing on that needs to be done once it gets back out of interrupt mode.

Historically, DOS and other non-protected OSes allowed software to modify the interrupt tables willy-nilly. This worked out okay when people who understood how interrupts were supposed to work were programming them, but it was also easy to completely screw over the state of the system with them. This is why modern, protected OSes don't typically allow user software to modify the interrupt tables. (If you're running in kernel mode as a driver, you can do it, but it's still really not a good idea.)

But, UNIX allows for user software to change its process's signal handlers. This is typically done to allow (for example) SIGHUP to tell Apache to reload its configuration files.

Modifying the interrupt table that the OS uses modifies that table for all software running on the system. This is generally not something that a user running a secure OS would particularly want, if they wanted to retain security of their system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.