Information Technology Reference
In-Depth Information
Branch Address
+4
CPU
Instructions
Fetch
Exec
New PC
Program
Counter
Select
PC
opcode
Figure2.3: The basic operation of a CPU.
2.2
Dual-mode operation
Once a program is loaded into memory, and the operating system starts the
process, the processor will fetch each instruction in turn, decode, and execute it.
Some instructions compute values, say, by multiplying two registers and putting
the result into another register. Some instructions read or write locations in
memory. Still other instructions like branches or procedure calls change the
program counter and thus determine next instruction to execute.
The basic
operation of a processor is illustrated in Figure 2.3.
How does the operating system kernel prevent a process from doing any
harm to other processes or to the operating system itself? After all, if multi-
ple programs are loaded into memory at the same time, what is to keep one
process from overwriting another process' data structures, or for that matter,
overwriting the operating system image stored on disk?
If we step back from any consideration of performance, a very simple, safe,
and entirely hypothetical approach would be to have the operating system kernel
simulate, step by step, every instruction in every user process. Instead of the
processor directly executing instructions, each instruction in a user program
would be fetched, decoded, and executed by a software interpreter. Before each
Search WWH ::




Custom Search