Information Technology Reference
In-Depth Information
what the current contents of the CPU registers are, what addresses are in the
program counter and the memory stack, and so on. When a process becomes
active, the operating system loads all of this information into the CPU and
restarts the program from where it left off. The operating system also needs
to have some “scheduling policy” to decide which should be the next process
to become active. There are many such scheduling policies that attempt to
ensure “fair” process selection - but most users would argue that none of
them are perfect!
Process5
Process1
CPU
Process4
Process2
Process3
Fig. 3.12. Perhaps the most important
task for an operating system is allocating
time on the CPU to different processes.
Each process is allowed to use the CPU
for a limited time.
Hardware interrupts
The next problem for the operating system is fundamental. Because the oper-
ating system is also a program and the CPU can only run one program at a
time, how can the operating system hand the CPU over to one process and
then get back control of the CPU so it can schedule another process? This is
done by a different type of interrupt, one that switches not between a pro-
cess and the operating system but between the actual computer hardware
and the operating system. It is called a hardware interrupt . Such an interrupt
happens when some event like a keyboard entry or mouse movement occurs.
The hardware interrupt changes the computer's operation from user mode
to supervisor mode . Supervisor mode is a method of operation in which the
operating system can access and use all of the computer's hardware and
instructions. By contrast, in user mode only a restricted set of hardware and
instructions are accessible to the program. At a hardware interrupt, the com-
puter jumps to the scheduler program. This software finds out what event has
happened and decides which user process should next gain control of the
CPU ( Fig. 3.12 ).
System calls
In addition to hiding the complexity of devices through standard interfaces
with device drivers ( Fig. 3.13 ) and scheduling user processes, the operating
system manages how programs request services from the hardware. When
user programs need to access and control devices directly, the role of the
operating system is to make sure they do so safely without causing damage
to the hardware. The operating system ensures the safety of the entire com-
puter system through a set of special-purpose functions called system calls.
System calls are the means by which programs request a service from the
operating system.
User programs
Operating system
Printer
driver
Camera
driver
CD
driver
File management
One special class of system calls has come to symbolize the entire operat-
ing system. These are the calls that create and manipulate the file system.
Computers store data in a hierarchical arrangement of iles or folders that are
accessed through “directories” on a hard disk. The hard disk , housed in a unit
called a hard drive consists of magnetic plates called platters that store infor-
mation. The computer reads and writes data to the disk. The operating system
has to keep track of the file names and be able to map them to their physical
location on the disk.
Fig. 3.13. A significant portion of the
code of an operating system is made up
of device drivers. These are programs
that operate various devices attached
to the computer, such as a printer, a
camcorder, or a CD player.
Search WWH ::




Custom Search