An operating system is intimately tied to the hardware of the computer it runs
on. It extends the computer’s instruction set and manages its resources. To work,
it must know a great deal about the hardware, at least about how the hardware ap-
pears to the programmer. For this reason, let us briefly review computer hardware
2/1/24
as found in modern personal computers. After that, we can start getting into the de-
tails of what operating systems do and how they work.
Conceptually, a simple personal computer can be abstracted to a model resem-
bling that of Fig. 1-6. The CPU, memory, and I/O devices are all connected by a
system bus and communicate with one another over it. Modern personal computers
have a more complicated structure, involving multiple buses, which we will look at
later. For the time being, this model will be sufficient. In the following sections,
we will briefly review these components and examine some of the hardware issues
Computer
that areHardware Review
of concern to operating (1) designers. Needless to say, this will be a
system
very compact summary. Many books have been written on the subject of computer
hardware and computer organization. Two well-known ones are by Tanenbaum
Components of a (2012)
and Austin simple personal
and Patterson computer
and Hennessy (2013).
Monitor
Hard
Keyboard USB printer disk drive
USB Hard
Video Keyboard
CPU Memory controller disk
controller controller
MMU controller
Bus
Operating
Figure 1-6. Some of theSystems
components of a simple personal computer. 15
15
Computer Hardware Review (2)
(a) A three-stage pipeline
(b) A superscalar CPU
Operating Systems 16
16
1
2/1/24
Computer Hardware Review (3)
SEC. 1.3 COMPUTER HARDWARE REVIEW 25
Typical access time Typical capacity
1 nsec Registers <1 KB
2 nsec Cache 4 MB
10 nsec Main memory 1-8 GB
10 msec Magnetic disk 1-4 TB
Figure 1-9. A typical memory hierarchy. The numbers are very rough approximations.
typically 32 × 32 bits on a 32-bit CPU and 64 × 64 bits on a 64-bit CPU. Less than
1 KB in both cases. Programs must manage the registers (i.e., decide what to keep
in them) themselves, in software.
Next comes the cache memory, which is mostly controlled by the hardware.
Main memory is divided up into cache Operating Systems
lines, typically 64 bytes, with addresses 0 17
to 63 in cache line 0, 64 to 127 in cache line 1, and so on. The most heavily used
17 cache lines are kept in a high-speed cache located inside or very close to the CPU.
When the program needs to read a memory word, the cache hardware checks to see
if the line needed is in the cache. If it is, called a cache hit, the request is satisfied
from the cache and no memory request is sent over the bus to the main memory.
Cache hits normally take about two clock cycles. Cache misses have to go to
memory, with a substantial time penalty. Cache memory is limited in size due to its
high cost. Some machines have two or even three levels of cache, each one slower
and bigger than the one before it.
Caching plays a major role in many areas of computer science, not just caching
lines of RAM. Whenever a resource can be divided into pieces, some of which are
used much more heavily than others, caching is often used to improve perfor-
mance. Operating systems use it all the time. For example, most operating systems
keep (pieces of) heavily used files in main memory to avoid having to fetch them
from the disk repeatedly. Similarly, the results of converting long path names like
/home/ast/projects/minix3/src/kernel/clock.c
into the disk address where the file is located can be cached to avoid repeated
lookups. Finally, when the address of a Web page (URL) is converted to a network
address (IP address), the result can be cached for future use. Many other uses exist.
In any caching system, several questions come up fairly soon, including:
1. When to put a new item into the cache.
2. Which cache line to put the new item in.
3. Which item to remove from the cache when a slot is needed.
4. Where to put a newly evicted item in
Operating the larger memory.
Systems 18
18
2
2/1/24
Computer Hardware Review (4)
Structure of a disk drive
Operating Systems 19
19
Operating Systems 20
20
3
2/1/24
Computer Hardware Review (5)
Operating Systems 21
21
Computer Hardware Review (5.2)
More sofisticated
Multiple users can share the same
program with only one copy of it in
memory
Two base-limit pairs
Operating Systems 22
22
4
2/1/24
Computer Hardware Review (6)
(Direct Memory Access)
Operating Systems 23
23
Computer Hardware Review (8)
Structure of a large Pentium system
Operating Systems 24
24
5
2/1/24
Operating Systems Concepts
• All operating systems have certain basic concepts that are
central to understanding them.
• Key OS concepts
• system calls, processes, files, and shell
• System calls
• set of “extended instructions” that OS provides
• used as interface between user programs and OS
• each system call corresponds to a library procedure
• procedure puts parameters in specified place (registers)
• issues a TRAP instruction that starts OS
• OS gets control after TRAP, performs requested work, then returns control to
library procedure
Operating Systems 25
25
Steps in Making a System Call
There are 11 steps in making the system call
read (fd, buffer, nbytes)
Operating Systems 26
26
6
2/1/24
Processes
• A process is a program in execution
• Address space: a list of memory locations which the process can read and
write. It contains: executable program, program’s data, and its stack.
• Set of registers: the program counter, stack pointer, and other hardware
registers
• In timesharing systems.
• When a process is suspended, it must later be restarted in exactly the same
state it had when it was stopped.
• All information about the process must be explicitly saved somewhere
during the suspension.
• Example: the process may have several files open for reading at once.
Associated with each of these files is a pointer giving the current position.
• All the information about each process, other than the content of its address
space, is stored in an OS table called the process table.
Operating Systems 27
27
Some System Calls For Process Management
– Key process management system calls
• creation/termination of processes
• allocate/deallocate memory
• create a child process and wait for child process to
terminate
• send signal to another process
Operating Systems 28
28