(steps 1 and 2 constitute the busy wait.) This same idea works for buffers as well as single characters: processor fills buffer (of maybe 512 characters), then uses busy wait for external device to signal that it has emptied the buffer. Though buffers are going to be more helpful if not using busy wait (why?)
This waste of valuable CPU time (due to speed mismatches between CPU and external devices) is reduced by introduction of hardware interrupts.
main memory addr | inst ------+-------- 100 | br 200 Assume HW supports 16 interrupts 101 | br 300 102 | br 350 104 | br 550 . . . . . . 115 | br 950 . . . . . . . . . . . .HW support: for each interrupt type (e.g. clock interrupt, IO completion, change to supervisor state, invalid instruction) the HW changes to program counter to a "prewired" memory address (in the above example, 100 for interrupt type 0, 101 for interrupt type 1, etc.) This results in the specific code to handle that interrupt being executed.
Examples:
Well, for one thing, this allows things the same machine code to be used in machines that don't have quite the same instruction sets (say, across a product line from cheap slow processors to expensive fast processors).
Once the hardware supports this, then I/O can be handled much more efficiently. It is also used for security. If some instructions are privileged, then if a "normal" process attempts to execute them, the OS (through interrupt code) can validate what is happening.
The point has been to do things FAST. So that things are only checked when they need to be. This requires a combination of HW and SW support.
Main Memory 0 +-------------+ | | To switch from J1 to J3, OS changes | OS | base register contents of 10000 to | | 60000. 10000 +-------------+ | | | J1 | This simplifies much system software. | | For example, compilers can now "pretend" 40000 +-------------+ that all code is loaded starting at | J2 | addr 0. | | 60000 +-------------+ | J3 | | | | | | | 90000 +-------------+ | J4 | | | | | +-------------+ |/////////////| |/////////////| +-------------+
Note: this is NOT checked in software (much too slow). It must be done in hardware as a side effect of addressing memory SO THAT NOTHING SLOWS MEMORY REFERENCES DOWN. THE SAME GOES FOR THE USE OF THE BASE REGISTER. If memory references are validated, the mechanism must be very fast.
How does the OS get around this? Two basic approaches:
Index | Previous | Next |
---|
Copyright ©2014, G. Hill Price
Send comments to G. Hill Price