|FROM ||Ruben Safir
|SUBJECT ||Subject: [LIU Comp Sci] (fwd) Re: Operating System Design
|From owner-learn-outgoing-at-mrbrklyn.com Wed Feb 4 13:23:18 2015
Received: by mrbrklyn.com (Postfix)
id 78CC816115D; Wed, 4 Feb 2015 13:23:18 -0500 (EST)
Received: by mrbrklyn.com (Postfix, from userid 28)
id 6B07C16115E; Wed, 4 Feb 2015 13:23:18 -0500 (EST)
Received: from mailbackend.panix.com (mailbackend.panix.com [22.214.171.124])
by mrbrklyn.com (Postfix) with ESMTP id BBAAC161168
for ; Wed, 4 Feb 2015 13:23:12 -0500 (EST)
Received: from panix2.panix.com (panix2.panix.com [126.96.36.199])
by mailbackend.panix.com (Postfix) with ESMTP id AC18E13093
for ; Wed, 4 Feb 2015 13:23:12 -0500 (EST)
Received: by panix2.panix.com (Postfix, from userid 20529)
id A7F7233CC5; Wed, 4 Feb 2015 13:23:12 -0500 (EST)
From: Ruben Safir
Subject: [LIU Comp Sci] (fwd) Re: Operating System Design
User-Agent: tin/2.0.0-20110823 ("Ardenistiel") (UNIX) (NetBSD/6.1.5 (i386))
Date: Wed, 4 Feb 2015 13:23:12 -0500 (EST)
-- forwarded message --
From: David Brown
Subject: Re: Operating System Design
Date: Fri, 30 Jan 2015 09:00:45 +0100
Organization: A noiseless patient Spider
Content-Type: text/plain; charset=UTF-8
Injection-Date: Fri, 30 Jan 2015 08:00:12 +0000 (UTC)
Injection-Info: mx02.eternal-september.org; posting-host="dc28719e2ffeeb5899be5f5057009353";
logging-data="28776"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/JIX8OkJrfbV9V5KCEwYK3rWhJzEQIg30="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
Xref: panix comp.os.linux.hardware:364728
On 29/01/15 23:11, ruben safir wrote:
> I'm wondering if anyone has a background in operating system design.
> I'm taking a class is OS's and the text is
> ABRAHAM SILBERSCHATZ
> 9th edition, and it says something that is puzzling me
> "Interrupts are an important part of a computer architecture. Each
> computer design has its own interrupt mechanism, but several functions
> are common. The interrupt must transfer control to the appropriate
> interrupt service routine. The straightforward method for handling this
> transfer would be to invoke a generic routine to examine the interrupt
> information. The routine, in turn, would call the interrupt-specific
> handler. However, interrupts must be handled quickly"
> " Since only a predefined number of interrupts is possible, a table of
> pointers to interrupt routines can be used instead*** to provide the
> necessary speed. The interrupt routine is called indirectly through the
> table, with no intermediate routine needed. Generally, the table of
> pointers is stored in low memory (the first hundred or so locations).
> These locations hold the addresses of the interrupt service routines for
> the various devices. This array, or interrupt vector, of addresses is
> then indexed by a unique device number, given with the interrupt
> request, to provide the address of the interrupt service routine for
> the interrupting device. Operating systems as different as Windows and
> UNIX dispatch interrupts in this manner."
> *** Instead of what? Just because you have a table of pointers to
> routines doesn't change the need for a routine, a generic routine
> perhaps, from accessing that table.
When a cpu receives an unmasked interrupt signal (you will probably
learn about masking interrupts later - generally, the OS can control
which interrupts are enabled), it must do three things:
1. It must pause execution of the current instruction stream
2. It must store critical state data so that normal execution can be
3. It must jump to some user/system code to handle the interrupt.
Step 1 here is mostly internal to the processor, and won't be visible to
the OS or programmers (except that it can affect the reaction time for
interrupts, which can be critical in embedded systems).
Step 2 varies tremendously between processor types, but it generally
involves storing a minimal set of registers in a safe place, so that the
software interrupt handler can run (and save other registers as needed).
CISC processors generally push the current stack pointer and the flag
register onto the stack. For more complex CISC processors such as the
68040, there can be other registers saved to keep track of the state of
long-running instructions (like block copy instructions). RISC
processors like the PPC save them in dedicated "interrupt save"
registers. Some processors, like the ARM responding to a "fast
interrupt", enable a dedicated register bank. And some, like the
Cortex-M3, save a number of registers so that the interrupt handlers can
be written as plain C functions without need for assembly or special
Step 3 is where the processor figures out what code to run next. This
again varies between processors. For some, there is a single fixed
address that is always used - then it is up to the user code to figure
out the source of the interrupt, and handle it (using a table of
function pointers, a switch statement, a series of if's, etc.). Some
processors have dedicated internal registers for interrupt routine
addresses. Some will have an interrupt controller module (either
builtin, or as a separate device) that figures out the interrupt source
and gets an appropriate handler address from internal registers or a
memory table. And other cpus get an interrupt number directly, and use
that to look up a table of handler addresses (typically based at a
However the handler address is discovered, the processor then jumps to
the code at that address. It is up to that code to figure out what
caused the interrupt (if the cpu supports a table of handlers, the code
will already have a fair idea). It also needs to store additional
registers and processor state, and then deal with the interrupt itself.
Afterwards it can either return to the interrupted code, or cause some
sort of context switch (a more advanced topic that you will get to later
in the book, I expect).
For most processors, this handler requires some assembly programming or
at least special compiler extensions and attributes - it is not a
"normal" C function. And there are always restrictions on how handler
code interacts with the OS and system calls.
A note on terminology - the term "interrupt vector" is sometimes used to
mean a table of pointers to interrupt handlers, as used in the quotation
you gave. But it can also be used to mean simply /a/ pointer to an
interrupt handler. Thus sometimes one talks about "a table of interrupt
vectors". I've tried to avoid the term here, to avoid confusion - I
recommend you do so too unless you make the meaning explicitly clear.
-- end of forwarded message --