1. Introduction OS Concept 10E (1)
1. Introduction OS Concept 10E (1)
Introduction
Internally, operating systems vary greatly in their makeup, since they are organized
along many different lines. The design of a new operating system is a major task,
and it is important that the goals of the system be well defined before the design
begins.
An operating system is software that manages a computer's hardware. It also provides a basis for
application programs and acts as an intermediary between the computer user and the computer
hardware. An amazing aspect of operating systems is how they vary in accomplishing these tasks
in a wide variety of computing environments. Operating systems are everywhere, from cars and
home appliances that include "Internet of Things" devices, to smart phones, personal computers,
enterprise computers, and cloud computing environments.
Chapter objectives
Section glossary
The hardware—the central processing unit (CPU), the memory, and the input/output (I/O) devices—
provides the basic computing resources for the system. The application programs—such as word
processors, spreadsheets, compilers, and web browsers—define the ways in which these
resources are used to solve users' computing problems. The operating system controls the
hardware and coordinates its use among the various application programs for the various users.
We can also view a computer system as consisting of hardware, software, and data. The operating
system provides the means for proper use of these resources in the operation of the computer
system. An operating system is similar to a government. Like a government, it performs no useful
function by itself. It simply provides an environment within which other programs can do useful
work.
To understand more fully the operating system's role, we next explore operating systems from two
viewpoints: that of the user and that of the system.
User view
The user's view of the computer varies according to the interface being used. Many computer
users sit with a laptop or in front of a PC consisting of a monitor, keyboard, and mouse. Such a
system is designed for one user to monopolize its resources. The goal is to maximize the work (or
play) that the user is performing. In this case, the operating system is designed mostly for ease of
use, with some attention paid to performance and security and none paid to resource utilization—
how various hardware and software resources are shared. ©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
Increasingly, many users interact with mobile devices such as smartphones and tablets—devices
AbdlAzizOSCOct2022
that are replacing desktop and laptop computer systems for some users. These devices are
typically connected to networks through cellular or other wireless technologies. The user interface
for mobile computers generally features a touch screen, where the user interacts with the system
by pressing and swiping fingers across the screen rather than using a physical keyboard and
mouse. Many mobile devices also allow users to interact through a voice recognition interface,
such as Apple's Siri.
Some computers have little or no user view. For example, embedded computers in home devices
and automobiles may have numeric keypads and may turn indicator lights on or off to show status,
but they and their operating systems and applications are designed primarily to run without user
intervention.
System view
From the computer's point of view, the operating system is the program most
©zyBooks intimately
10/20/22 involved
18:14 1496583
with the hardware. In this context, we can view an operating system as Noraisyah
a resourceAbdl Aziz
allocator. A
AbdlAzizOSCOct2022
computer system has many resources that may be required to solve a problem: CPU time, memory
space, storage space, I/O devices, and so on. The operating system acts as the manager of these
resources. Facing numerous and possibly conflicting requests for resources, the operating system
must decide how to allocate them to specific programs and users so that it can operate the
computer system efficiently and fairly.
A slightly different view of an operating system emphasizes the need to control the various I/O
devices and user programs. An operating system is a control program. A control program
manages the execution of user programs to prevent errors and improper use of the computer. It is
especially concerned with the operation and control of I/O devices.
By now, you can probably see that the term operating system covers many roles and functions.
That is the case, at least in part, because of the myriad designs and uses of computers.
Computers are present within toasters, cars, ships, spacecraft, homes, and businesses. They are
the basis for game machines, cable TV tuners, and industrial control systems.
To explain this diversity, we can turn to the history of computers. Although computers have a
relatively short history, they have evolved rapidly. Computing started as an experiment to determine
what could be done and quickly moved to fixed-purpose systems for military uses, such as code
breaking and trajectory plotting, and governmental uses, such as census calculation. Those early
computers evolved into general-purpose, multifunction mainframes, and that's when operating
systems were born. In the 1960s, Moore's Law predicted that the number of transistors on an
integrated circuit would double every 18 months, and that prediction has held true. Computers
gained in functionality and shrank in size, leading to a vast number of uses and a vast number and
variety of operating systems. (See Appendix A for more details on the history of operating
systems.)
How, then, can we define what an operating system is? In general, we have no completely
adequate definition of an operating system. Operating systems exist because they offer a
©zyBooks 10/20/22 18:14 1496583
reasonable way to solve the problem of creating a usable computing system. TheAbdl
Noraisyah fundamental
Aziz
AbdlAzizOSCOct2022
goal of computer systems is to execute programs and to make solving user problems easier.
Computer hardware is constructed toward this goal. Since bare hardware alone is not particularly
easy to use, application programs are developed. These programs require certain common
operations, such as those controlling the I/O devices. The common functions of controlling and
allocating resources are then brought together into one piece of software: the operating system.
In addition, we have no universally accepted definition of what is part of the operating system. A
simple viewpoint is that it includes everything a vendor ships when you order "the operating
system." The features included, however, vary greatly across systems. Some systems take up less
than a megabyte of space and lack even a full-screen editor, whereas others require gigabytes of
space and are based entirely on graphical windowing systems. A more common definition, and the
one that we usually follow, is that the operating system is the one program running at all times on
the computer—usually called the kernel. Along with the kernel, there are two other types of
programs: system programs, which are associated with the operating system but are not
necessarily part of the kernel, and application programs, which include all programs not associated
with the operation of the system. ©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
There are also awkward bits of code that defy categorization. Device drivers for example manage
hardeware devices, run within the kernel, but are frequently provided by the hardware
manufacturer. They are arguably part of the operating system or possibly thought of as being a
layer between the hardware and the operating system. Another confusion comes from loadable
kernel modules. These chunks of compiled code sometimes come with the operating system (for
example, a non-default file system) and are automatically loaded by the system as needed.
Sometimes the system administrator adds and can manage these modules (for example, adding a
file system that doesn't ship with the operating system). So here we have a component running
within the operating system that didn't ship with it.
Further complicating the definition of an operating system is the difference between common
understanding and reality. Most people think of their computer as running \quoted{an operating
system}. But if we define an operating system as constantly running, and managing hardware, then
we need to consider the \bf{many} operating systems running on a common computer. The \CPU\
has firmware{\mdash} software embedded in the hardware{\mdash} the motherboard has \BIOS\
code that boots and manages it, and devices have firmware managing their functionality. In reality,
there might be more code running in these other operating systems than in the main general-
purpose operating system. We discuss some of these aspects further in this book but mostly
constrain coverage to the general-purpose operating system.
So, where does that leave us in our quest to define a general-purpose computer's
\quoted{operating system}? A reasonable summary is that the operating system is inclusive of the
kernel that is loaded at boot time, any device drivers and kernel functions loaded at run time, and
any system programs related to the operation of the system (as opposed to applications). The
operating system is the piece of software that sits between the hardware and applications,
providing a set of services to the computer and users, and is not part of the firmware or hardware
logic.
The matter of what constitutes an operating system became increasingly important as personal
computers became more widespread and operating systems grew increasingly sophisticated. In
1998, the United States Department of Justice filed suit against Microsoft, in essence claiming that
©zyBooks 10/20/22 18:14 1496583
Microsoft included too much functionality in its operating systems and thus prevented application
Noraisyah Abdl Aziz
vendors from competing. (For example, a web browser was an integralAbdlAzizOSCOct2022
part of Microsoft's
operating systems.) As a result, Microsoft was found guilty of using its operating-system
monopoly to limit competition.
Today, however, if we look at operating systems for mobile devices, we see that once again the
number of features constituting the operating system is increasing. Mobile operating systems
often include not only a core kernel but also middleware—a set of software frameworks that
provide additional services to application developers. For example, each of the two most
prominent mobile operating systems—Apple's IOS and Google's Android—features a core kernel
along with middleware that supports databases, multimedia, and graphics (to name only a few).
In summary, for our purposes, the operating system includes the always-running kernel,
middleware frameworks that ease application development and provide features, and system
programs that aid in managing the system while it is running. Most of this text is concerned with
the kernel of general-purpose operating systems, but other components are discussed as needed
to fully explain operating system design and operation.
PARTICIPATION
ACTIVITY 1.1.1: Section review questions.
hardware: The CPU, memory devices, input/output (I/O) devices, and any other
physical components that are part of a computer.
kernel: The operating system component running on the computer at all times
after system boot.
system program: A program associated with the operating system but not
necessarily part of the kernel.
middleware: A set of software frameworks that provide additional services to
application developers.
Fi 121 At i l PC t t
Figure 1.2.1: A typical PC computer system.
Typically, operating systems have a device driver for each device controller. This device driver
understands the device controller and provides the rest of the operating system with a uniform
interface to the device. The CPU and the device controllers can execute in parallel, competing for
memory cycles. To ensure orderly access to the shared memory, a memory controller
synchronizes access to the memory.
In the following subsections, we describe some basics of how such a system operates, focusing
on three key aspects of the system. We start with interrupts, which alert the CPU to events that
require attention. We then discuss storage structure and I/O structure.
Interrupts
Consider a typical computer operation: a program performing I/O. To start an I/O operation, the
device driver loads the appropriate registers in the device controller. The device controller, in turn,
examines the contents of these registers to determine what action to take (such as "read a
character from the keyboard"). The controller starts the transfer of data from the device to its local
buffer. Once the transfer of data is complete, the device controller informs the device driver that it
has finished its operation. The device driver then gives control to other parts of the operating
system, possibly returning the data or a pointer to the data if the operation was a read. For other
operations, the device driver returns status information such as "write completed successfully" or
©zyBooks 10/20/22 18:14 1496583
"device busy". But how does the controller inform the device driver that Noraisyah
it has finished its
Abdl Aziz
operation? This is accomplished via an interrupt. AbdlAzizOSCOct2022
Overview
Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the
system bus. (There may be many buses within a computer system, but the system bus is the main
communications path between the major components.) Interrupts are used for many other
purposes as well and are a key part of how operating systems and hardware interact.
When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a
fixed location. The fixed location usually contains the starting address where the service routine for
the interrupt is located. The interrupt service routine executes; on completion, the CPU resumes
the interrupted computation. A timeline of this operation is shown in the animation below.
Animation content:
Step 1: The user program runs. The I/O device receives an I/O request.
Step 2: The I/O device transfers data. The I/O device then finishes
the transfer and signals an interrupt. The CPU receives the interrupt
and halts the execution of the user program. Eventually, the execution
resumes. Step 3: The I/O device receives another I/O request. Step 4:
The I/O device transfers data and signals another interrupt. The CPU
receives the interrupt and handles the interrupt. Once the I/O
interrupt is handled, the CPU resumes execution of the user program.
Animation captions:
1. The user program runs. The I/O device receives an I/O request.
2. The I/O device transfers data. The I/O device then finishes the transfer and signals an
interrupt. The CPU receives the interrupt and halts the execution of the user program.
Eventually, the execution resumes.
3. The I/O device receives another I/O request.
4. The I/O device transfers data and signals another interrupt. The CPU receives the interrupt
and handles the interrupt. Once the I/O interrupt is handled, the CPU resumes execution of
the user program.
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 managing 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, as they occur very
©zyBooks 10/20/22 18:14 1496583
frequently. A table of pointers to interrupt routines can be used instead Noraisyah
to provideAbdl
the Aziz
necessary
speed. The interrupt routine is called indirectly through the table, with no intermediate routine
AbdlAzizOSCOct2022
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 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.
The interrupt architecture must also save the state information of whatever was interrupted, so
that it can restore this information after servicing the interrupt. If the interrupt routine needs to
modify the processor state—for instance, by modifying register values—it must explicitly save the
current state and then restore that state before returning. After the interrupt is serviced, the saved
return address is loaded into the program counter, and the interrupted computation resumes as
though the interrupt had not occurred.
PARTICIPATION
ACTIVITY
1.2.2: Interrupt-driven I/O Cycle.
Animation content:
Step One: Device driver senses device I/O activity, initiates I/O.
Step 2: Driver tells I/O controller to initiate I/O. Step 3: While I/O
executes, the CPU checks for interrupts between instructions. Step 4:
The device completes its operation, generates an interrupt which is
received by the CPU. Step 5. CPU jumps to interrupt handler which
processes the interrupt, returns from interrupt handler. Step 6: CPU
resumes task that was interrupted. Step 7: Ready for the next
interrupt to start the cycle again.
Animation captions:
©zyBooks 10/20/22 18:14 1496583
1. Device driver senses device I/O activity, initiates I/O. Noraisyah Abdl Aziz
2. Driver tells I/O controller to initiate I/O. AbdlAzizOSCOct2022
3. While I/O executes, the CPU checks for interrupts between instructions.
4. The device completes its operation, generates an interrupt which is received by the CPU.
5. CPU jumps to interrupt handler which processes the interrupt, returns from interrupt
handler.
6. CPU resumes task that was interrupted.
7. Ready for the next interrupt to start the cycle again.
The basic interrupt mechanism just described enables the CPU to respond to an asynchronous
event, as when a device controller becomes ready for service. In a modern operating system,
however, we need more sophisticated interrupt-handling features.
2. We need an efficient way to dispatch to the proper interrupt handler for a device.
Most CPUs have two interrupt request lines. One is the nonmaskable interrupt, which is reserved
for events such as unrecoverable memory errors. The second interrupt line is maskable: it can be
turned off by the CPU before the execution of critical instruction sequences that must not be
interrupted. The maskable interrupt is used by device controllers to request service.
Recall that the purpose of a vectored interrupt mechanism is to reduce the need for a single
interrupt handler to search all possible sources of interrupts to determine which one needs service.
In practice, however, computers have more devices (and, hence, interrupt handlers) than they have
address elements in the interrupt vector. A common way to solve this problem is to use interrupt
chaining, in which each element in the interrupt vector points to the head of a list of interrupt
handlers. When an interrupt is raised, the handlers on the corresponding list are called one by one,
until one is found that can service the request. This structure is a compromise between the
overhead of a huge interrupt table and the inefficiency of dispatching to a single interrupt handler.
Figure 1.2.2 illustrates the design of the interrupt vector for Intel processors. The events from 0 to
31, which are nonmaskable, are used to signal various error conditions. The events from 32 to 255,
which are maskable, are used for purposes such as device-generated interrupts.
The interrupt mechanism also implements a system of interrupt priority levels. These levels
enable the CPU to defer the handling of low-priority interrupts without masking all interrupts and
makes it possible for a high-priority interrupt to preempt the execution of a low-priority interrupt.
In summary, interrupts are used throughout modern operating systems to handle asynchronous
events (and for other purposes we will discuss throughout the text). Device controllers and
hardware faults raise interrupts. To enable the most urgent work to be done first, modern
computers use a system of interrupt priorities. Because interrupts are used so heavily for time-
sensitive processing, efficient interrupt handling is required for good system performance.
Storage structure
The CPU can load instructions only from memory, so any programs must first
©zyBooks be loaded
10/20/22 into
18:14 1496583
memory to run. General-purpose computers run most of their programsNoraisyah
from rewritable
Abdl Azizmemory,
AbdlAzizOSCOct2022
called main memory (also called random-access memory, or RAM). Main memory commonly is
implemented in a semiconductor technology called dynamic random-access memory (DRAM).
Computers use other forms of memory as well. For example, the first program to run on computer
power-on is a bootstrap program, which then loads the operating system. Since RAM is volatile—
loses its content when power is turned off or otherwise lost—we cannot trust it to hold the
bootstrap program. Instead, for this and some other purposes, the computer uses electrically
erasable programmable read-only memory (EEPROM) and other forms of firmware—storage that is
infrequently written to and is nonvolatile. EEPROM can be changed but cannot be changed
frequently. In addition, it is low speed, and so it contains mostly static programs and data that
aren't frequently used. For example, the iPhone uses EEPROM to store serial numbers and
hardware information about the device.
All forms of memory provide an array of bytes. Each byte has its own address. Interaction is
achieved through a sequence of load or store instructions to specific memory addresses. The
load instruction moves a byte or word from main memory to an internal register within the CPU,
whereas the store instruction moves the content of a register to main memory. Aside from
explicit loads and stores, the CPU automatically loads instructions from main memory for
execution from the location stored in the program counter.
©zyBooks 10/20/22 18:14 1496583
Noraisyah
A typical instruction-execution cycle, as executed on a system with a von Neumann Abdlarchitecture,
Aziz
AbdlAzizOSCOct2022
first fetches an instruction from memory and stores that instruction in the instruction register. The
instruction is then decoded and may cause operands to be fetched from memory and stored in
some internal register. After the instruction on the operands has been executed, the result may be
stored back in memory. Notice that the memory unit sees only a stream of memory addresses. It
does not know how they are generated (by the instruction counter, indexing, indirection, literal
addresses, or some other means) or what they are for (instructions or data). Accordingly, we can
ignore how a memory address is generated by a program. We are interested only in the sequence
of memory addresses generated by the running program.
Ideally, we want the programs and data to reside in main memory permanently. This arrangement
usually is not possible on most systems for two reasons:
1. Main memory is usually too small to store all needed programs and data permanently.
The most common secondary-storage devices are hard-disk drives (HDDs) and nonvolatile
memory (NVM) devices, which provide storage for both programs and data. Most programs
(system and application) are stored in secondary storage until they are loaded into memory. Many
programs then use secondary storage as both the source and the destination of their processing.
Secondary storage is also much slower than main memory. Hence, the proper management of
secondary storage is of central importance to a computer system, as we discuss in the chapter
Mass-Storage Structure.
In a larger sense, however, the storage structure that we have described—consisting of registers,
main memory, and secondary storage—is only one of many possible storage system designs.
Other possible components include cache memory, CD-ROM or blu-ray, magnetic tapes, and so on.
Those that are slow enough and large enough that they are used only for special purposes—to
store backup copies of material stored on other devices, for example—are called tertiary storage.
Each storage system provides the basic functions of storing a datum and holding that datum until
it is retrieved at a later time. The main differences among the various storage systems lie in speed,
size, and volatility.
The wide variety of storage systems can be organized in a hierarchy (Figure 1.2.3) according to
storage capacity and access time. As a general rule, there is a trade-off between size and speed,
with smaller and faster memory closer to the CPU. As shown in the figure, in addition to differing in
speed and capacity, the various storage systems are either volatile or nonvolatile. Volatile storage,
as mentioned earlier, loses its contents when the power to the device is removed, so data must be
written to nonvolatile storage for safekeeping.
The top four levels of memory in the figure are constructed using semiconductor memory, which
consists of semiconductor-based electronic circuits. NVM devices, at the fourth level, have several
variants but in general are faster than hard disks. The most common form of NVM device is flash
memory, which is popular in mobile devices such as smartphones and tablets. Increasingly, flash
memory is being used for long-term storage on laptops, desktops, and servers as well.
Since storage plays an important role in operating-system structure, we will refer to it frequently in
the text. In general, we will use the following terminology:
Mechanical storage is generally larger and less expensive per byte than electrical storage.
Conversely, electrical storage is typically costly, smaller, and faster than mechanical storage.
The design of a complete storage system must balance all the factors just discussed: it must use
only as much expensive memory as necessary while providing as much inexpensive, nonvolatile
storage as possible. Caches can be installed to improve performance where a large disparity in
access time or transfer rate exists between two components.
I/O structure
PARTICIPATION
ACTIVITY
1.2.3: How a modern computer works.
Animation content:
1. The CPU core instruction cycle involves reading instructions and read and writing data to
main memory.
2. An instruction might trigger an I/O request to a device.
3. That request leads to data transfer with the device, and an interrupt to signal the CPU when
the transfer is complete.
4. For larger mass media data movement, an instruction requests the I/O.
5. The I/O request triggers a DMA transfer of data from the device to main memory.
6. The interrupt informs the CPU of the I/O completion.
maskable: Describes an interrupt that can be delayed or blocked (such as when the
kernel is in a critical section).
bootstrap program: The program that allows the computer to start running by
initializing hardware and loading the kernel.
volatile: Describes storage whose content can be lost in a power outage or similar
event.
firmware: Software stored in ROM or EEPROM for booting the system and
managing low level hardware.
bit: The basic unit of computer storage. A bit can contain one of two values, 0 or 1.
nonvolatile storage (NVS): Storage in which data will not be lost in a power outage
or similar event.
Single-processor systems
Many years ago, most computer systems used a single processor containing one CPU with a
single processing core. The core is the component that executes instructions and registers for
storing data locally. The one main CPU with its core is capable of executing a general-purpose
instruction set, including instructions from processes. These systems have other special-purpose
processors as well. They may come in the form of device-specific processors, such as disk,
keyboard, and graphics controllers.
All of these special-purpose processors run a limited instruction set and do not run processes.
Sometimes, they are managed by the operating system, in that the operating system sends them
information about their next task and monitors their status. For example, a disk-controller
microprocessor receives a sequence of requests from the main CPU core and implements its own
©zyBooks 10/20/22 18:14 1496583
disk queue and scheduling algorithm. This arrangement relieves the main CPU ofAbdl
Noraisyah the Aziz
overhead of
disk scheduling. PCs contain a microprocessor in the keyboard to convertAbdlAzizOSCOct2022
the keystrokes into
codes to be sent to the CPU. In other systems or circumstances, special-purpose processors are
low-level components built into the hardware. The operating system cannot communicate with
these processors; they do their jobs autonomously. The use of special-purpose microprocessors is
common and does not turn a single-processor system into a multiprocessor. If there is only one
general-purpose CPU with a single processing core, then the system is a single-processor system.
According to this definition, however, very few contemporary computer systems are single-
processor systems.
Multiprocessor systems
On modern computers, from mobile devices to servers, multiprocessor systems now dominate the
landscape of computing. Traditionally, such systems have two (or more) processors, each with a
single-core CPU. The processors share the computer bus and sometimes the clock, memory, and
peripheral devices. The primary advantage of multiprocessor systems is increased throughput.
That is, by increasing the number of processors, we expect to get more work done in less time. The
speed-up ratio with N processors is not N , however; it is less than N . When multiple processors
cooperate on a task, a certain amount of overhead is incurred in keeping all the parts working
correctly. This overhead, plus contention for shared resources, lowers the expected gain from
additional processors.
The most common multiprocessor systems use symmetric multiprocessing (SMP), in which each
peer CPU processor performs all tasks, including operating-system functions and user processes.
Figure 1.3.1 illustrates a typical SMP architecture with two processors, each with its own CPU.
Notice that each CPU processor has its own set of registers, as well as a private—or local—cache.
However, all processors share physical memory over the system bus.
The benefit of this model is that many processes can run simultaneously—N processes can run if
there are N CPUs—without causing performance to deteriorate significantly. However, since the
CPUs are separate, one may be sitting idle while another is overloaded, resulting in inefficiencies.
These inefficiencies can be avoided if the processors share certain data structures. A
multiprocessor system of this form will allow processes and resources—such as memory—to be
shared dynamically among the various processors and can lower the workload variance among
the processors. Such a system must be written carefully, as we shall see in the chapter CPU
Scheduling and the chapter Synchronization Tools.
The definition of multiprocessor has evolved over time and now includes multicore systems, in
which multiple computing cores reside on a single chip. Multicore systems can be more efficient
than multiple chips with single cores because on-chip communication is faster than between-chip
communication. In addition, one chip with multiple cores uses significantly less power than
multiple single-core chips, an important issue for mobile devices as well as laptops.
In Figure 1.3.2, we show a dual-core design with two cores on the same processor chip. In this
design, each core has its own register set, as well as its own local cache, often known as a level 1,
or L1, cache. Notice, too, that a level 2 (L2) cache is local to the chip but is shared by the two
©zyBooks 10/20/22 18:14 1496583
processing cores. Most architectures adopt this approach, combining local and shared
Noraisyah caches,
Abdl Aziz
where local, lower-level caches are generally smaller and faster than higher-level shared caches.
AbdlAzizOSCOct2022
Aside from architectural considerations, such as cache, memory, and bus contention, a multicore
processor with N cores appears to the operating system as N standard CPUs. This characteristic
puts pressure on operating-system designers—and application programmers—to make efficient
use of these processing cores, an issue we pursue in the chapter Threads & Concurrency. Virtually
all modern operating systems—including Windows, macOS, and Linux, as well as Android and iOS
mobile systems—support multicore SMP systems.
Figure 1.3.2: A dual-core design with two cores on the same chip.
Although virtually all systems are now multicore, we use the general term CPU
when referring to a single computational unit of a computer system and core as
well as multicore when specifically referring to one or more cores on a CPU.
PARTICIPATION
ACTIVITY
1.3.2: Mid-section review question.
©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
1) Multicore also means multiple CPUs. AbdlAzizOSCOct2022
True
False
Adding additional CPUs to a multiprocessor system will increase computing power; however, as
suggested earlier, the concept does not scale very well, and once we add too many CPUs,
contention for the system bus becomes a bottleneck and performance begins to degrade. An
alternative approach is instead to provide each CPU (or group of CPUs) with its own local memory
that is accessed via a small, fast local bus. The CPUs are connected by a shared system
interconnect, so that all CPUs share one physical address space. This approach—known as non-
uniform memory access, or NUMA—is illustrated in Figure 1.3.3. The advantage is that, when a
CPU accesses its local memory, not only is it fast, but there is also no contention over the system
interconnect. Thus, NUMA systems can scale more effectively as more processors are added.
A potential drawback with a NUMA system is increased latency when a CPU must access remote
memory across the system interconnect, creating a possible performance penalty. In other words,
for example, CPU0 cannot access the local memory of CPU3 as quickly as it can access its own
local memory, slowing down performance. Operating systems can minimize this NUMA penalty
through careful CPU scheduling and memory management, as discussed in Section Multicore
Processors and Section Non-Uniform Memory Access. Because NUMA systems can scale to
accommodate a large number of processors, they are becoming increasingly popular on servers
as well as high-performance computing systems.
Finally, blade servers are systems in which multiple processor boards, I/O boards, and networking
boards are placed in the same chassis. The difference between these and traditional
©zyBooks 10/20/22 18:14 1496583
multiprocessor systems is that each blade-processor board boots independently and Aziz
Noraisyah Abdl runs its own
operating system. Some blade-server boards are multiprocessor as well, AbdlAzizOSCOct2022
which blurs the lines
between types of computers. In essence, these servers consist of multiple independent
multiprocessor systems.
Clustered systems
Another type of multiprocessor system is a clustered system, which gathers together multiple
CPUs. Clustered systems differ from the multiprocessor systems described in Section
Multiprocessor systems in that they are composed of two or more individual systems—or nodes—
joined together; each node is typically a multicore system. Such systems are considered loosely
coupled. We should note that the definition of clustered is not concrete; many commercial and
open-source packages wrestle to define what a clustered system is and why one form is better
than another. The generally accepted definition is that clustered computers share storage and are
closely linked via a local-area network LAN (as described in the chapter Networks and Distributed
Systems) or a faster interconnect, such as InfiniBand.
Clustering is usually used to provide high-availability service—that is, service that will continue
even if one or more systems in the cluster fail. Generally, we obtain high availability by adding a
level of redundancy in the system. A layer of cluster software runs on the cluster nodes. Each node
can monitor one or more of the others (over the network). If the monitored machine fails, the
monitoring machine can take ownership of its storage and restart the applications that were
running on the failed machine. The users and clients of the applications see only a brief
interruption of service.
High availability provides increased reliability, which is crucial in many applications. The ability to
continue providing service proportional to the level of surviving hardware is called graceful
degradation. Some systems go beyond graceful degradation and are called fault tolerant, because
they can suffer a failure of any single component and still continue operation. Fault tolerance
requires a mechanism to allow the failure to be detected, diagnosed, and, if possible, corrected.
PC motherboard
Consider the desktop PC motherboard with a processor socket shown below:
This board is a fully functioning computer, once its slots are populated. It consists
of a processor socket containing a CPU, DRAM sockets, PCIe bus slots, and I/O
connectors of various types. Even the lowest-cost general-purpose CPU contains
multiple cores. Some motherboards contain multiple processor sockets. More
advanced computers allow more than one system board, creating NUMA systems.
Since a cluster consists of several computer systems connected via a network, clusters can also
be used to provide high-performance computing environments. Such systems can supply
significantly greater computational power than single-processor or even SMP systems because
they can run an application concurrently on all computers in the cluster. The application must have
been written specifically to take advantage of the cluster, however. This involves a technique
known as parallelization, which divides a program into separate components that run in parallel on
individual cores in a computer or computers in a cluster. Typically, these applications are designed
so that once each computing node in the cluster has solved its portion of the problem, the results
from all the nodes are combined into a final solution.
Other forms of clusters include parallel clusters and clustering over a wide-area network (WAN) (as
described in the chapter Networks and Distributed Systems). Parallel clusters allow multiple hosts
to access the same data on shared storage. Because most operating ©zyBooks 10/20/22
systems lack18:14 1496583
support for
Noraisyah Abdl Aziz
simultaneous data access by multiple hosts, parallel clusters usually require the use of special
AbdlAzizOSCOct2022
versions of software and special releases of applications. For example, Oracle Real Application
Cluster is a version of Oracle's database that has been designed to run on a parallel cluster. Each
machine runs Oracle, and a layer of software tracks access to the shared disk. Each machine has
full access to all data in the database. To provide this shared access, the system must also supply
access control and locking to ensure that no conflicting operations occur. This function, commonly
known as a distributed lock manager (DLM), is included in some cluster technology.
Cluster technology is changing rapidly. Some cluster products support thousands of systems in a
cluster, as well as clustered nodes that are separated by miles. Many of these improvements are
made possible by storage-area networks (SANs), as described in a Section Storage-Area Networks
and Storage Arrays, which allow many systems to attach to a pool of storage. If the applications
and their data are stored on the SAN, then the cluster software can assign the application to run on
any host that is attached to the SAN. If the host fails, then any other host can take over. In a
database cluster, dozens of hosts can share the same database, greatly increasing performance
©zyBooks
and reliability. Figure 1.3.4 depicts the general structure of a clustered 10/20/22 18:14 1496583
system.
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
PARTICIPATION
ACTIVITY
1.3.3: Section review questions.
Section glossary
core: Within a CPU, the component that executes instructions.
multicore: Multiple processing cores within the same CPU chip or within a single
system.
multiprocessor: multiple processors within the same cpu chip or within a single
system.
shared system interconnect: A bus connecting CPUs to memory in such a way that
all CPUs can access all system memory; the basis for NUMA systems.
blade server: A computer with multiple processor boards, I/O boards, and
networking boards placed in the same chassis. The difference between these and
traditional multiprocessor systems is that each blade-processor board boots
independently and runs its own operating system.
high-availability: Describes a service that will continue even if one or more systems
in the cluster fail.
graceful degradation: The ability of a system to continue providing service
proportional to the level of surviving hardware.
fault-tolerant system: A system that can suffer a failure of any single component
©zyBooks 10/20/22 18:14 1496583
and still continue operation. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
asymmetric clustering: A configuration in which one machine in a cluster is in hot-
standby mode while the other is running applications.
For a computer to start running—for instance, when it is powered up or rebooted—it needs to have
an initial program to run. As noted earlier, this initial program, or bootstrap program, tends to be
simple. Typically, it is stored within the computer hardware in firmware. It initializes all aspects of
the system, from CPU registers to device controllers to memory contents. The bootstrap program
must know how to load the operating system and how to start executing that system. To
accomplish this goal, the bootstrap program must locate the operating-system kernel and load it
into memory.
Hadoop
1. A distributed file system that manages data and files across distributed
computing nodes.
2. The YARN ("Yet Another Resource Negotiator") framework, which manages
resources within the cluster as well as scheduling tasks on nodes in the
cluster.
©zyBooks 10/20/22 18:14 1496583
3. The MapReduce system, which allows parallel processing ofNoraisyah
data across
Abdl Aziz
nodes in the cluster. AbdlAzizOSCOct2022
Once the kernel is loaded and executing, it can start providing services to the system and its users.
Some services are provided outside of the kernel by system programs that are loaded into memory
at boot time to become system daemons, which run the entire time the kernel is running. On Linux,
the first system program is "systemd," and it starts many other daemons. Once this phase is
complete, the system is fully booted, and the system waits for some event to occur.
If there are no processes to execute, no I/O devices to service, and no users to whom to respond,
an operating system will sit quietly, waiting for something to happen. Events are almost always
signaled by the occurrence of an interrupt. In Section Interrupts we described hardware interrupts.
Another form of interrupt is a trap (or an exception), which is a software-generated interrupt
caused either by an error (for example, division by zero or invalid memory access) or by a specific
request from a user program that an operating-system service be performed by executing a
special operation called a system call.
One of the most important aspects of operating systems is the ability to run
©zyBooks multiple
10/20/22 programs,
18:14 1496583as
a single program cannot, in general, keep either the CPU or the I/O devices busy at
Noraisyah all Aziz
Abdl times.
AbdlAzizOSCOct2022
Furthermore, users typically want to run more than one program at a time as well.
Multiprogramming increases CPU utilization, as well as keeping users satisfied, by organizing
programs so that the CPU always has one to execute. In a multiprogrammed system, a program in
execution is termed a process.
The idea is as follows: The operating system keeps several processes in memory simultaneously
(Figure 1.4.1). The operating system picks and begins to execute one of these processes.
Eventually, the process may have to wait for some task, such as an I/O operation, to complete. In a
non-multiprogrammed system, the CPU would sit idle. In a multiprogrammed system, the
operating system simply switches to, and executes, another process. When that process needs to
wait, the CPU switches to another process, and so on. Eventually, the first process finishes waiting
and gets the CPU back. As long as at least one process needs to execute, the CPU is never idle.
This idea is common in other life situations. A lawyer does not work for only one client at a time,
for example. While one case is waiting to go to trial or have papers typed, the lawyer can work on
another case. If she has enough clients, the lawyer will never be idle for lack of work. (Idle lawyers
tend to become politicians, so there is a certain social value in keeping lawyers busy.)
Multitasking is a logical extension of multiprogramming. In multitasking systems, the CPU
executes multiple processes by switching among them, but the switches occur frequently,
providing the user with a fast response time. Consider that when a process executes, it typically
executes for only a short time before it either finishes or needs to perform I/O. I/O may be
interactive; that is, output goes to a display for the user, and input comes from a user keyboard,
mouse, or touch screen. Since interactive I/O typically runs at "people speeds," it may take a long
time to complete. Input, for example, may be bounded by the user's typing speed; seven characters
per second is fast for people but incredibly slow for computers. Rather than let the CPU sit idle as
this interactive input takes place, the operating system will rapidly switch the CPU to another
process. ©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
Having several processes in memory at the same time requires some form of memory
AbdlAzizOSCOct2022
management, which we cover in the chapter Main Memory and chapter Virtual Memory. In
addition, if several processes are ready to run at the same time, the system must choose which
process will run next. Making this decision is CPU scheduling, which is discussed in the chapter
CPU Scheduling. Finally, running multiple processes concurrently requires that their ability to affect
one another be limited in all phases of the operating system, including process scheduling, disk
storage, and memory management. We discuss these considerations throughout the text.
In a multitasking system, the operating system must ensure reasonable response time. A common
method for doing so is virtual memory, a technique that allows the execution of a process that is
not completely in memory (chapter Virtual Memory). The main advantage of this scheme is that it
enables users to run programs that are larger than actual physical memory. Further, it abstracts
main memory into a large, uniform array of storage, separating logical memory as viewed by the
user from physical memory. This arrangement frees programmers from concern over memory-
storage limitations.
©zyBooks 10/20/22 18:14 1496583
Multiprogramming and multitasking systems must also provide a file system (chapter
Noraisyah File-System
Abdl Aziz
Interface, chapter File-System Implementation, and chapter File-SystemAbdlAzizOSCOct2022
Internals). The file system
resides on a secondary storage; hence, storage management must be provided (chapter Mass-
Storage Structure). In addition, a system must protect resources from inappropriate use (chapter
Protection). To ensure orderly execution, the system must also provide mechanisms for process
synchronization and communication (chapter Synchronization Tools and chapter Synchronization
Examples), and it may ensure that processes do not get stuck in a deadlock, forever waiting for
one another (chapter Deadlocks).
Since the operating system and its users share the hardware and software resources of the
computer system, a properly designed operating system must ensure that an incorrect (or
malicious) program cannot cause other programs—or the operating system itself—to execute
incorrectly. In order to ensure the proper execution of the system, we must be able to distinguish
between the execution of operating-system code and user-defined code. The approach taken by
most computer systems is to provide hardware support that allows differentiation among various
modes of execution.
At the very least, we need two separate modes of operation: user mode and kernel mode (also
called supervisor mode, system mode, or privileged mode). A bit, called the mode bit, is added to
the hardware of the computer to indicate the current mode: kernel (0) or user (1). With the mode
bit, we can distinguish between a task that is executed on behalf of the operating system and one
that is executed on behalf of the user. When the computer system is executing on behalf of a user
application, the system is in user mode. However, when a user application requests a service from
the operating system (via a system call), the system must transition from user to kernel mode to
fulfill the request. This is shown in Figure 1.4.2. As we shall see, this architectural enhancement is
useful for many other aspects of system operation as well.
At system boot time, the hardware starts in kernel mode. The operating system is then loaded and
starts user applications in user mode. Whenever a trap or interrupt occurs, the hardware switches
from user mode to kernel mode (that is, changes the state of the mode bit to 0). Thus, whenever
the operating system gains control of the computer, it is in kernel mode. The system always
switches to user mode (by setting the mode bit to 1) before passing control to a user program.
The dual mode of operation provides us with the means for protecting the operating system from
errant users—and errant users from one another. We accomplish this protection by designating
some of the machine instructions that may cause harm as privileged instructions. The hardware
allows privileged instructions to be executed only in kernel mode. If an attempt is made to execute
a privileged instruction in user mode, the hardware does not execute the instruction but rather
treats it as illegal and traps it to the operating system.
The instruction to switch to kernel mode is an example of a privileged instruction. Some other
examples include I/O control, timer management, and interrupt management. Many additional
privileged instructions are discussed throughout the text.
The concept of modes can be extended beyond two modes. For example, Intel processors have
four separate protection rings, where ring 0 is kernel mode and ring 3 is user mode. (Although
rings 1 and 2 could be used for various operating-system services, in practice they are rarely used.)
ARM v8 systems have seven modes. CPUs that support virtualization (Section Virtual machines
'Overview') frequently have a separate mode to indicate when the virtual machine manager (VMM)
is in control of the system. In this mode, the VMM has more privileges than user processes but
fewer than the kernel. It needs that level of privilege so it can create and manage virtual machines,
changing the CPU state to do so.
We can now better understand the life cycle of instruction execution in a computer system. Initial
control resides in the operating system, where instructions are executed in kernel mode. When
control is given to a user application, the mode is set to user mode. Eventually, control is switched
back to the operating system via an interrupt, a trap, or a system ©zyBooks
call. Most10/20/22
contemporary
18:14 1496583
operating systems—such as Microsoft Windows, Unix, and Linux—take Noraisyah
advantageAbdl
of this
Aziz dual-
mode feature and provide greater protection for the operating system. AbdlAzizOSCOct2022
System calls provide the means for a user program to ask the operating system to perform tasks
reserved for the operating system on the user program's behalf. A system call is invoked in a
variety of ways, depending on the functionality provided by the underlying processor. In all forms, it
is the method used by a process to request action by the operating system. A system call usually
takes the form of a trap to a specific location in the interrupt vector. This trap can be executed by a
generic trap instruction, although some systems have a specific syscall instruction to invoke a
system call.
When a system call is executed, it is typically treated by the hardware as a software interrupt.
Control passes through the interrupt vector to a service routine in the operating system, and the
mode bit is set to kernel mode. The system-call service routine is a part of the operating system.
The kernel examines the interrupting instruction to determine what system call has occurred; a
parameter indicates what type of service the user program is requesting. Additional information
©zyBooks 10/20/22 18:14 1496583
needed for the request may be passed in registers, on the stack, or in memory (with
Noraisyah Abdlpointers
Aziz to the
AbdlAzizOSCOct2022
memory locations passed in registers). The kernel verifies that the parameters are correct and
legal, executes the request, and returns control to the instruction following the system call. We
describe system calls more fully in Section 2.3.
Once hardware protection is in place, it detects errors that violate modes. These errors are
normally handled by the operating system. If a user program fails in some way—such as by making
an attempt either to execute an illegal instruction or to access memory that is not in the user's
address space—then the hardware traps to the operating system. The trap transfers control
through the interrupt vector to the operating system, just as an interrupt does. When a program
error occurs, the operating system must terminate the program abnormally. This situation is
handled by the same code as a user-requested abnormal termination. An appropriate error
message is given, and the memory of the program may be dumped. The memory dump is usually
written to a file so that the user or programmer can examine it and perhaps correct it and restart
the program.
Timer
We must ensure that the operating system maintains control over the CPU. We cannot allow a user
program to get stuck in an infinite loop or to fail to call system services and never return control to
the operating system. To accomplish this goal, we can use a timer. A timer can be set to interrupt
the computer after a specified period. The period may be fixed (for example, 1/60 second) or
variable (for example, from 1 millisecond to 1 second). A variable timer is generally implemented
by a fixed-rate clock and a counter. The operating system sets the counter. Every time the clock
ticks, the counter is decremented. When the counter reaches 0, an interrupt occurs. For instance, a
10-bit counter with a 1-millisecond clock allows interrupts at intervals from 1 millisecond to 1,024
milliseconds, in steps of 1 millisecond.
Before turning over control to the user, the operating system ensures that the timer is set to
interrupt. If the timer interrupts, control transfers automatically to the operating system, which may
treat the interrupt as a fatal error or may give the program more time. Clearly, instructions that
modify the content of the timer are privileged. ©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
Linux timers
Section glossary
big data: Extremely large sets of data; distributed systems are well suited to
working with big data.
MapReduce: A Google-created big data programming model and implementation
for parallel processing across nodes in a distributed cluster. A layer on top of the
Google file system (GFS), it allows developers to carry out large-scale parallel
computations easily.
system daemon: A service that is provided outside the kernel by system programs
that are loaded into memory at boot time and run continuously.
trap: A software interrupt. The interrupt can be caused either by an error
©zyBooks (e.g.,18:14 1496583
10/20/22
Noraisyah Abdl Aziz
division by zero or invalid memory access) or by a specific request from a user
AbdlAzizOSCOct2022
program that an operating-system service be performed.
response time: The amount of time it takes the system to respond to user action.
CPU scheduling: The process by which the system chooses which job will run next
If several jobs are ready to run at the same time.
virtual memory: A technique that allows the execution of a process that is not
completely in memory. Also, separation of computer memory address space from
physical into logical, allowing easier programming and larger name space.
logical memory: Memory as viewed by the user; usually a large uniform array, not
matching physical memory in virtual memory systems.
user mode: A CPU mode for executing user processes in which some instructions
are limited or not allowed. See also kernel mode.
kernel mode: A CPU mode in which all instructions are enabled. The kernel runs in
this mode. See also user mode.
©zyBooks 10/20/22 18:14 1496583
Noraisyah
supervisor mode: A CPU mode in which all instructions are enabled. Abdl Aziz
The kernel
AbdlAzizOSCOct2022
runs in this mode. See also user mode.
system mode: A CPU mode in which all instructions are enabled. The kernel runs in
this mode. See also user mode.
privileged mode: A CPU mode in which all instructions are enabled. The kernel runs
in this mode. See also user mode.
mode bit: A CPU status bit used to indicate the current mode: kernel (0) or user (1).
privileged instructions: Instructions that can execute only if the CPU is in in kernel
mode.
virtual machine manager (VMM): The computer function that manages the virtual
machine; also called a hypervisor.
©zyBooks 10/20/22 18:14 1496583
timer: A hardware component that can be set to interrupt the computer after
Noraisyah a Aziz
Abdl
specified period. AbdlAzizOSCOct2022
Process management
A program can do nothing unless its instructions are executed by a CPU. A program in execution,
as mentioned, is a process. A program such as a compiler is a process, and a word-processing
program being run by an individual user on a PC is a process. Similarly, a social media app on a
mobile device is a process. For now, you can consider a process to be an instance of a program in
execution, but later you will see that the concept is more general. As described in the chapter
Processes, it is possible to provide system calls that allow processes to create subprocesses to
execute concurrently.
A process needs certain resources—including CPU time, memory, files, and I/O devices—to
accomplish its task. These resources are typically allocated to the process while it is running. In
addition to the various physical and logical resources that a process obtains when it is created,
various initialization data (input) may be passed along. For example, consider a process running a
web browser whose function is to display the contents of a web page on a screen. The process will
be given the URL as an input and will execute the appropriate instructions
©zyBooks and system
10/20/22 18:14calls to
1496583
obtain and display the desired information on the screen. When the process terminates,
Noraisyah Abdl Azizthe
operating system will reclaim any reusable resources. AbdlAzizOSCOct2022
We emphasize that a program by itself is not a process. A program is a passive entity, like the
contents of a file stored on disk, whereas a process is an active entity. A single-threaded process
has one program counter specifying the next instruction to execute. (Threads are covered in the
chapter Threads & Concurrency.) The execution of such a process must be sequential. The CPU
executes one instruction of the process after another, until the process completes. Further, at any
time, one instruction at most is executed on behalf of the process. Thus, although two processes
may be associated with the same program, they are nevertheless considered two separate
execution sequences. A multithreaded process has multiple program counters, each pointing to
the next instruction to execute for a given thread.
A process is the unit of work in a system. A system consists of a collection of processes, some of
which are operating-system processes (those that execute system code) and the rest of which are
user processes (those that execute user code). All these processes can potentially execute
concurrently—by multiplexing on a single CPU core—or in parallel across multiple CPU cores.
©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
The operating system is responsible for the following activities in connection with process
AbdlAzizOSCOct2022
management:
Memory management
As discussed in Section Storage structure, the main memory is central to the operation of a
modern computer system. Main memory is a large array of bytes, ranging in size from hundreds of
thousands to billions. Each byte has its own address. Main memory is a repository of quickly
accessible data shared by the CPU and I/O devices. The CPU reads instructions from main
memory during the instruction-fetch cycle and both reads and writes data from main memory
during the data-fetch cycle (on a von Neumann architecture). As noted earlier, the main memory is
generally the only large storage device that the CPU is able to address and access directly. For
example, for the CPU to process data from disk, those data must first be transferred to main
memory by CPU-generated I/O calls. In the same way, instructions must be in memory for the CPU
to execute them.
For a program to be executed, it must be mapped to absolute addresses and loaded into memory.
As the program executes, it accesses program instructions and data from memory by generating
these absolute addresses. Eventually, the program terminates, its memory space is declared
available, and the next program can be loaded and executed.
To improve both the utilization of the CPU and the speed of the computer's response to its users,
general-purpose computers must keep several programs in memory, creating a need for memory
©zyBooks 10/20/22 18:14 1496583
management. Many different memory-management schemes are used.Noraisyah These schemes
Abdl Azizreflect
AbdlAzizOSCOct2022
various approaches, and the effectiveness of any given algorithm depends on the situation. In
selecting a memory-management scheme for a specific system, we must take into account many
factors—especially the hardware design of the system. Each algorithm requires its own hardware
support.
The operating system is responsible for the following activities in connection with memory
management:
Keeping track of which parts of memory are currently being used and which process is using
them
Allocating and deallocating memory space as needed
Deciding which processes (or parts of processes) and data to move into and out of memory
Memory-management techniques are discussed in the chapter Main Memory and chapter Virtual
Memory.
©zyBooks 10/20/22 18:14 1496583
File-system management Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
To make the computer system convenient for users, the operating system provides a uniform,
logical view of information storage. The operating system abstracts from the physical properties of
its storage devices to define a logical storage unit, the file. The operating system maps files onto
physical media and accesses these files via the storage devices.
File management is one of the most visible components of an operating system. Computers can
store information on several different types of physical media. Secondary storage is the most
common, but tertiary storage is also possible. Each of these media has its own characteristics and
physical organization. Most are controlled by a device, such as a disk drive, that also has its own
unique characteristics. These properties include access speed, capacity, data-transfer rate, and
access method (sequential or random).
A file is a collection of related information defined by its creator. Commonly, files represent
programs (both source and object forms) and data. Data files may be numeric, alphabetic,
alphanumeric, or binary. Files may be free-form (for example, text files), or they may be formatted
rigidly (for example, fixed fields such as an mp3 music file). Clearly, the concept of a file is an
extremely general one.
The operating system implements the abstract concept of a file by managing mass storage media
and the devices that control them. In addition, files are normally organized into directories to make
them easier to use. Finally, when multiple users have access to files, it may be desirable to control
which user may access a file and how that user may access it (for example, read, write, append).
The operating system is responsible for the following activities in connection with file
management:
Mass-storage management
As we have already seen, the computer system must provide secondary storage to back up main
memory. Most modern computer systems use HDDs and NVM devices as the principal on-line
storage media for both programs and data. Most programs—including compilers, web browsers,
word processors, and games—are stored on these devices until loaded into memory. The
programs then use the devices as both the source and the destination of their processing. Hence,
the proper management of secondary storage is of central importance to a computer system. The
operating system is responsible for the following activities in connection with secondary storage
management:
Because secondary storage is used frequently and extensively, it must be used efficiently. The
entire speed of operation of a computer may hinge on the speeds of the secondary storage
subsystem and the algorithms that manipulate that subsystem.
At the same time, there are many uses for storage that is slower and lower in cost (and sometimes
higher in capacity) than secondary storage. Backups of disk data, storage of seldom-used data,
and long-term archival storage are some examples. Magnetic tape drives and their tapes and CD,
DVD, and Blu-ray drives and platters are typical tertiary storage devices.
Tertiary storage is not crucial to system performance, but it still must be managed. Some
operating systems take on this task, while others leave tertiary-storage management to application
programs. Some of the functions that operating systems can provide include mounting and
unmounting media in devices, allocating and freeing the devices for exclusive use by processes,
and migrating data from secondary to tertiary storage.
Techniques for secondary storage and tertiary storage management are discussed in the chapter
Mass-Storage Structure.
Cache management
Other caches are implemented totally in hardware. For instance, most systems have an instruction
cache to hold the instructions expected to be executed next. Without this cache, the CPU would
have to wait several cycles while an instruction was fetched from main memory. For similar
reasons, most systems have one or more high-speed data caches in the memory hierarchy. We are
not concerned with these hardware-only caches in this text, since they are outside the control of
the operating system.
Because caches have limited size, cache management is an important design problem. Careful
selection of the cache size and of a replacement policy can result in greatly increased
performance, as you can see by examining Figure 1.5.1. Replacement algorithms for software-
controlled caches are discussed in the chapter Virtual Memory.
The movement of information between levels of a storage hierarchy may be either explicit or
implicit, depending on the hardware design and the controlling operating-system software. For
instance, data transfer from cache to CPU and registers is usually a hardware function, with no
operating-system intervention. In contrast, transfer of data from disk to memory is usually
controlled by the operating system.
In a hierarchical storage structure, the same data may appear in different levels of the storage
system. For example, suppose that an integer A that is to be incremented by 1 is located in file B,
and file B resides on hard disk. The increment operation proceeds by first issuing an I/O operation
to copy the disk block on which A resides to main memory. This operation is followed by copying A
to the cache and to an internal register. Thus, the copy of A appears in several places: on the hard
disk, in main memory, in the cache, and in an internal register (see Figure 1.5.2). Once the
increment takes place in the internal register, the value of A differs in the various storage systems.
The value of A becomes the same only after the new value of A is written from the internal register
back to the hard disk.
In a distributed environment, the situation becomes even more complex. In this environment,
several copies (or replicas) of the same file can be kept on different computers. Since the various
replicas may be accessed and updated concurrently, some distributed systems ensure that, when
a replica is updated in one place, all other replicas are brought up to date as soon as possible.
There are various ways to achieve this guarantee, as we discuss in the chapter Networks and
Distributed Systems.
One of the purposes of an operating system is to hide the peculiarities of specific hardware
devices from the user. For example, in UNIX, the peculiarities of I/O devices are hidden from the
bulk of the operating system itself by the I/O subsystem. The I/O subsystem consists of several
components:
Only the device driver knows the peculiarities of the specific device to which it is assigned.
We discussed earlier in this chapter how interrupt handlers and device drivers are used in the
construction of efficient I/O subsystems. In the chapter I/O Systems, we discuss how the I/O
subsystem interfaces to the other system components, manages devices, transfers data, and
detects I/O completion.
PARTICIPATION
ACTIVITY
1.5.1: Section review questions.
program counter: A CPU register indicating the main memory location of the next
instruction to load and execute.
file: The smallest logical storage unit; a collection of related information defined by
its creator.
caching: The use of temporary data storage areas to improve performance.
cache coherency: The coordination of the contents of caches such that an update
to a value stored in one cache is immediately reflected in all other caches that hold
that value.
I/O subsystem: The I/O devices and the part of the kernel that manages I/O.
Protection and security require the system to be able to distinguish among all its users. Most
operating systems maintain a list of user names and associated user identifiers (user IDs). In
Windows parlance, this is a security ID (SID). These numerical IDs are unique, one per user. When a
user logs in to the system, the authentication stage determines the appropriate user ID for the
user. That user ID is associated with all of the user's processes and threads. When an ID needs to
be readable by a user, it is translated back to the user name via the user name list.
In some circumstances, we wish to distinguish among sets of users rather than individual users.
For example, the owner of a file on a UNIX system may be allowed to issue all operations on that
file, whereas a selected set of users may be allowed only to read the file. To accomplish this, we
need to define a group name and the set of users belonging to that group. Group functionality can
be implemented as a system-wide list of group names and group identifiers. A user can be in one
or more groups, depending on operating-system design decisions. The user's group IDs are also
included in every associated process and thread.
In the course of normal system use, the user ID and group ID for a user are sufficient. However, a
user sometimes needs to escalate privileges to gain extra permissions for an activity. The user
may need access to a device that is restricted, for example. Operating systems provide various
methods to allow privilege escalation. On UNIX, for instance, the setuid attribute on a program
causes that program to run with the user ID of the owner of the file, rather than the current user's
ID. The process runs with this effective UID until it turns off the extra privileges or terminates.
PARTICIPATION
©zyBooks 10/20/22 18:14 1496583
ACTIVITY
1.6.1: Section review questions. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
protection: A category of system calls. Any mechanism for controlling the access
of processes or users to the resources defined by a computer system.
©zyBooks 10/20/22 18:14 1496583
security: The defense of a system from external and internal attacks. Such Abdl
Noraisyah attacks
Aziz
include viruses and worms, denial-of-service attacks, identity theft, and theft of
AbdlAzizOSCOct2022
service.
user identifier (user ID) (UID): A unique numerical user identifier.
user IDs: A unique numerical user identifier.
security ID (SID): In Windows, a value used to uniquely identify a user or group for
security purposes.
group identifier: Similar to a user identifier, but used to identify a group of users to
determine access rights.
escalate privileges: To gain extra permissions for an activity, as when a user needs
access to a device that is restricted.
effective UID: The UID the process is currently using, which can be different from
the login UID due to, e.g., escalating privileges.
1.7 Virtualization
Virtualization is a technology that allows us to abstract the hardware of a single computer (the
CPU, memory, disk drives, network interface cards, and so forth) into several different execution
environments, thereby creating the illusion that each separate environment is running on its own
private computer. These environments can be viewed as different individual operating systems (for
example, Windows and UNIX) that may be running at the same time and may interact with each
other. A user of a virtual machine can switch among the various operating systems in the same
way a user can switch among the various processes running concurrently in a single
©zyBooks 10/20/22 operating
18:14 1496583
system. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
Virtualization allows operating systems to run as applications within other operating systems. At
first blush, there seems to be little reason for such functionality. But the virtualization industry is
vast and growing, which is a testament to its utility and importance.
Broadly speaking, virtualization software is one member of a class that also includes emulation.
Emulation, which involves simulating computer hardware in software, is typically used when the
source CPU type is different from the target CPU type. For example, when Apple switched from the
IBM Power CPU to the Intel x86 CPU for its desktop and laptop computers, it included an emulation
facility called "Rosetta," which allowed applications compiled for the IBM CPU to run on the Intel
CPU. That same concept can be extended to allow an entire operating system written for one
platform to run on another. Emulation comes at a heavy price, however. Every machine-level
instruction that runs natively on the source system must be translated to the equivalent function
on the target system, frequently resulting in several target instructions. If the source and target
CPUs have similar performance levels, the emulated code may run much more slowly than the
native code. ©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
With virtualization, in contrast, an operating system that is natively compiled for a particular CPU
architecture runs within another operating system also native to that CPU. Virtualization first came
about on IBM mainframes as a method for multiple users to run tasks concurrently. Running
multiple virtual machines allowed (and still allows) many users to run tasks on a system designed
for a single user. Later, in response to problems with running multiple Microsoft Windows
applications on the Intel x86 CPU, VMware created a new virtualization technology in the form of
an application that ran on Windows. That application ran one or more guest copies of Windows or
other native x86 operating systems, each running its own applications. (See Figure 1.7.1.) Windows
was the host operating system, and the VMware application was the virtual machine manager
(VMM). The VMM runs the guest operating systems, manages their resource use, and protects
each guest from the others.
Figure 1.7.1: A computer running (a) a single operating system and (b)
three virtual machines.
Even though modern operating systems are fully capable of running multiple applications reliably,
the use of virtualization continues to grow. On laptops and desktops, a VMM allows the user to
install multiple operating systems for exploration or to run applications written for operating
systems other than the native host. For example, an Apple laptop running macOS on the x86 CPU
can run a Windows 10 guest to allow execution of Windows applications. Companies writing
software for multiple operating systems can use virtualization to run all of those operating
systems on a single physical server for development, testing, and debugging. Within data centers,
virtualization has become a common method of executing and managing computing
environments. VMMs like VMware ESXand Citrix XenServer no longer run on host operating
systems but rather are the host operating systems, providing services and resource management
to virtual machine processes.
©zyBooks 10/20/22 18:14 1496583
With this text, we provide a Linux virtual machine that allows you to runNoraisyah
Linux—asAbdl
wellAziz
as the
development tools we provide—on your personal system regardless ofAbdlAzizOSCOct2022
your host operating system.
Full details of the features and implementation of virtualization can be found in a later chapter
PARTICIPATION
ACTIVITY
1.7.1: Section review questions.
Section glossary
host: In virtualization, the location of the virtual machine manager, which runs
guest operating systems; generally, a computer.
virtual machine manager (VMM): The computer function that manages the virtual
machine; also called a hypervisor.
1.8 Distributed systems
A distributed system is a collection of physically separate, possibly heterogeneous computer
©zyBooks 10/20/22 18:14 1496583
systems that are networked to provide users with access to the variousNoraisyah
resources that
Abdl the system
Aziz
maintains. Access to a shared resource increases computation speed,AbdlAzizOSCOct2022
functionality, data
availability, and reliability. Some operating systems generalize network access as a form of file
access, with the details of networking contained in the network interface's device driver. Others
make users specifically invoke network functions. Generally, systems contain a mix of the two
modes—for example FTP and NFS. The protocols that create a distributed system can greatly
affect that system's utility and popularity.
A network, in the simplest terms, is a communication path between two or more systems.
Distributed systems depend on networking for their functionality. Networks vary by the protocols
used, the distances between nodes, and the transport media. TCP/IP is the most common network
protocol, and it provides the fundamental architecture of the Internet. Most operating systems
support TCP/IP, including all general-purpose ones. Some systems support proprietary protocols
to suit their needs. For an operating system, it is necessary only that a network protocol have an
interface device—a network adapter, for example—with a device driver to manage it, as well as
software to handle data. These concepts are discussed throughout this book.
Networks are characterized based on the distances between their nodes. A local-area network
(LAN) connects computers within a room, a building, or a campus. A wide-area network (WAN)
usually links buildings, cities, or countries. A global company may have a WAN to connect its
offices worldwide, for example. These networks may run one protocol or several protocols. The
continuing advent of new technologies brings about new forms of networks. For example, a
metropolitan-area network (MAN) could link buildings within a city. BlueTooth and 802.11 devices
use wireless technology to communicate over a distance of several feet, in essence creating a
personal-area network (PAN) between a phone and a headset or a smartphone and a desktop
computer.
The media to carry networks are equally varied. They include copper wires, fiber strands, and
wireless transmissions between satellites, microwave dishes, and radios. When computing devices
are connected to cellular phones, they create a network. Even very short-range infrared
communication can be used for networking. At a rudimentary level, whenever computers
communicate, they use or create a network. These networks also vary in their performance and
©zyBooks 10/20/22 18:14 1496583
reliability. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
Some operating systems have taken the concept of networks and distributed systems further than
the notion of providing network connectivity. A network operating system is an operating system
that provides features such as file sharing across the network, along with a communication
scheme that allows different processes on different computers to exchange messages. A
computer running a network operating system acts autonomously from all other computers on the
network, although it is aware of the network and is able to communicate with other networked
computers. A distributed operating system provides a less autonomous environment. The different
computers communicate closely enough to provide the illusion that only a single operating system
controls the network. We cover computer networks and distributed systems in a later chapter.
PARTICIPATION
ACTIVITY
1.8.1: Section review questions.
Section glossary
network operating system: A type of operating system that provides features such
as file sharing across a network, along with a communication scheme that allows
different processes on different computers to exchange messages. It provides an
environment in which users can access remote resources by remote login or data
transfer between remote and local systems.
©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
After arrays, lists are perhaps the most fundamental data structures in computer science. Whereas
each item in an array can be accessed directly, the items in a list must be accessed in a particular
order. That is, a list represents a collection of data values as a sequence. The most common
method for implementing this structure is a linked list, in which items are linked to one another.
Linked lists are of several types:
In a singly linked list, each item points to its successor, as illustrated in Figure 1.9.1.
In a doubly linked list, a given item can refer either to its predecessor or to its successor, as
illustrated in Figure 1.9.2.
In a circularly linked list, the last element in the list refers to the first element, rather than to
null, as illustrated in Figure 1.9.3.
Linked lists accommodate items of varying sizes and allow easy insertion and deletion of items.
One potential disadvantage of using a list is that performance for retrieving a specified item in a list
of size n is linear—O(n), as it requires potentially traversing all n elements in the worst case. Lists
are sometimes used directly by kernel algorithms. Frequently, though, they are used for
constructing more powerful data structures, such as stacks and queues.
A stack is a sequentially ordered data structure that uses the last in, first out (LIFO) principle for
adding and removing items, meaning that the last item placed onto a stack is the first item
removed. The operations for inserting and removing items from a stack are known as push and
pop, respectively. An operating system often uses a stack when invoking function calls.
Parameters, local variables, and the return address are pushed onto the stack when a function is
called; returning from the function call pops those items off the stack.
A queue, in contrast, is a sequentially ordered data structure that uses the first in, first out (FIFO)
principle: items are removed from a queue in the order in which they were inserted. There are many
everyday examples of queues, including shoppers waiting in a checkout line at a store and cars
waiting in line at a traffic signal. Queues are also quite common in operating systems—jobs that
are sent to a printer are typically printed in the order in which they were submitted, for example. As
we shall see in the chapter CPU Scheduling, tasks that are waiting to be run on an available CPU
are often organized in queues.
Trees
A tree is a data structure that can be used to represent data hierarchically. Data values in a tree
structure are linked through parent-child relationships. In a general tree, a parent may have an
unlimited number of children. In a binary tree, a parent may have at most two children, which we
term the left child and the right child. A binary search tree additionally requires an ordering
between the parent's two children in which left_child <= right_child. Figure 1.9.4 provides an
©zyBooks 10/20/22 18:14 1496583
example of a binary search tree. When we search for an item in a binaryNoraisyah
search tree,
Abdlthe
Azizworst-
case performance is O (n ) (consider how this can occur). To remedy this situation, we can use an
AbdlAzizOSCOct2022
algorithm to create a balanced binary search tree. Here, a tree containing n items has at most
lg n levels, thus ensuring worst-case performance of O (lg n ). We shall see Section
Example:Linux Scheudling in a later section that Linux uses a balanced binary search tree (known
as a red-black tree) as part its CPU-scheduling algorithm.
A hash function takes data as its input, performs a numeric operation on the data, and returns a
numeric value. This numeric value can then be used as an index into a table (typically an array) to
quickly retrieve the data. Whereas searching for a data item through a list of size n can require up
to O(n) comparisons, using a hash function for retrieving data from a table can be as good as O(1),
depending on implementation details. Because of this performance, hash functions are used
extensively in operating systems.
One potential difficulty with hash functions is that two unique inputs can result in the same output
value—that is, they can link to the same table location. We can accommodate this hash collision by
having a linked list at the table location that contains all of the items with the same hash value. Of
course, the more collisions there are, the less efficient the hash function is.
One use of a hash function is to implement a hash map, which associates (or maps) [key:value]
pairs using a hash function. Once the mapping is established, we can apply the hash function to
the key to obtain the value from the hash map (Figure 1.9.5). For example, suppose that a user
name is mapped to a password. Password authentication then proceeds as follows: a user enters
her user name and password. The hash function is applied to the user name, which is then used to
retrieve the password. The retrieved password is then compared with the password entered by the
user for authentication.
Bitmaps
A bitmap is a string of n binary digits that can be used to represent the status of n items. For
example, suppose we have several resources, and the availability of each resource is indicated by
the value of a binary digit: 0 means that the resource is available, while 1 indicates that it is
unavailable (or vice versa). The value of the ith position in the bitmap is associated with the ith
resource. As an example, consider the bitmap shown below:
0 0 1 0 1 1 1 0 1
The data structures used in the Linux kernel are available in the kernel source code.
The include file <linux/list.h> provides details of the linked-list data structure
used throughout the kernel. A queue in Linux is known as a kfifo, and its
implementation can be found in the kfifo.c file in the kernel directory of the
source code. Linux also provides a balanced binary search tree implementation
using red-black trees. Details can be found in the include file <linux/rbtree.h>.
The power of bitmaps becomes apparent when we consider their space efficiency. If we were to
use an eight-bit Boolean value instead of a single bit, the resulting©zyBooks 10/20/22
data structure 18:14be
would 1496583
eight
Noraisyah Abdl Aziz
times larger. Thus, bitmaps are commonly used when there is a need to represent the availability of
AbdlAzizOSCOct2022
a large number of resources. Disk drives provide a nice illustration. A medium-sized disk drive
might be divided into several thousand individual units, called disk blocks. A bitmap can be used to
indicate the availability of each disk block.
In summary, data structures are pervasive in operating system implementations. Thus, we will see
the structures discussed here, along with others, throughout this text as we explore kernel
algorithms and their implementations.
PARTICIPATION
ACTIVITY
1.9.1: Section review questions.
Section glossary
linked list: A data structure in which items are linked to one another.
stack: A sequentially ordered data structure that uses the last-in, first-out (LIFO)
principle for adding and removing items; the last item placed onto a stack is the
first item removed.
queue: A sequentially ordered data structure that uses the first-in, first-out (FIFO)
principle; items are removed from a queue in the order in which they were inserted.
tree: A data structure that can be used to represent data hierarchically; data values
in a tree structure are linked through parent-child relationships.
general tree: A tree data structure in which a parent may have unlimited children.
binary tree: A tree data structure in which a parent may have at most two children.
binary search tree: A type of binary tree data structure that requires an ordering
between the parent's two children in which left child <= right©zyBooks
child. 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
balanced binary search tree: A tree containing n items that has, at most, lg n
AbdlAzizOSCOct2022
levels, thus ensuring worst-case performance of O (lg n).
red-black tree: A tree containing n items and having at most lg n levels, thus
ensuring worst-case performance of O(lg n).
hash function: A function that takes data as its input, performs a numeric operation
on the data, and returns a numeric value. Also, an algorithm for creating a hash (a
small, fixed-size block of data calculated from a larger data set, used to determine
if a message has been changed).
hash map: A data structure that maps [key:value] pairs using a hash function; a
hash function can then be applied to a key to obtain its matching value.
bitmap: A string of n binary digits that can be used to represent the status of n
items. The availability of each item is indicated by the value of a binary digit: 0
means that the resource is available, while 1 indicates that ©zyBooks
it is unavailable (or18:14
10/20/22 vice-1496583
Noraisyah Abdl Aziz
versa).
AbdlAzizOSCOct2022
Traditional computing
As computing has matured, the lines separating many of the traditional computing environments
have blurred. Consider the "typical office environment." Just a few years ago, this environment
consisted of PCs connected to a network, with servers providing file and print services. Remote
access was awkward, and portability was achieved by use of laptop computers.
Today, web technologies and increasing WAN bandwidth are stretching the boundaries of
traditional computing. Companies establish portals, which provide web accessibility to their
internal servers. Network computers (or thin clients)—which are essentially terminals that
understand web-based computing—are used in place of traditional workstations where more
security or easier maintenance is desired. Mobile computers can synchronize with PCs to allow
very portable use of company information. Mobile devices can also connect to wireless networks
and cellular data networks to use the company's web portal (as well as the myriad other web
resources).
At home, most users once had a single computer with a slow modem connection to the office, the
Internet, or both. Today, network-connection speeds once available only at great cost are relatively
inexpensive in many places, giving home users more access to more data. These fast data
connections are allowing home computers to serve up web pages ©zyBooks 10/20/22
and to run 18:14that
networks 1496583
include
Noraisyah Abdl Aziz
printers, client PCs, and servers. Many homes use firewalls to protect their networks from security
AbdlAzizOSCOct2022
breaches. Firewalls limit the communications between devices on a network.
In the latter half of the 20th century, computing resources were relatively scarce. (Before that, they
were nonexistent!) For a period of time, systems were either batch or interactive. Batch systems
processed jobs in bulk, with predetermined input from files or other data sources. Interactive
systems waited for input from users. To optimize the use of the computing resources, multiple
users shared time on these systems. These time-sharing systems used a timer and scheduling
algorithms to cycle processes rapidly through the CPU, giving each user a share of the resources.
Traditional time-sharing systems are rare today. The same scheduling technique is still in use on
desktop computers, laptops, servers, and even mobile computers, but frequently all the processes
are owned by the same user (or a single user and the operating system). User processes, and
system processes that provide services to the user, are managed so that each frequently gets a
slice of computer time. Consider the windows created while a user is working on a PC, for
©zyBooks 10/20/22 18:14 1496583
example, and the fact that they may be performing different tasks at theNoraisyah
same time.
AbdlEven
Aziz a web
browser can be composed of multiple processes, one for each websiteAbdlAzizOSCOct2022
currently being visited, with
time sharing applied to each web browser process.
Mobile computing
Mobile computing refers to computing on handheld smartphones and tablet computers. These
devices share the distinguishing physical features of being portable and lightweight. Historically,
compared with desktop and laptop computers, mobile systems gave up screen size, memory
capacity, and overall functionality in return for handheld mobile access to services such as e-mail
and web browsing. Over the past few years, however, features on mobile devices have become so
rich that the distinction in functionality between, say, a consumer laptop and a tablet computer
may be difficult to discern. In fact, we might argue that the features of a contemporary mobile
device allow it to provide functionality that is either unavailable or impractical on a desktop or
laptop computer.
Today, mobile systems are used not only for e-mail and web browsing but also for playing music
and video, reading digital books, taking photos, and recording and editing high-definition video.
Accordingly, tremendous growth continues in the wide range of applications that run on such
devices. Many developers are now designing applications that take advantage of the unique
features of mobile devices, such as global positioning system (GPS) chips, accelerometers, and
gyroscopes. An embedded GPS chip allows a mobile device to use satellites to determine its
precise location on Earth. That functionality is especially useful in designing applications that
provide navigation—for example, telling users which way to walk or drive or perhaps directing them
to nearby services, such as restaurants. An accelerometer allows a mobile device to detect its
orientation with respect to the ground and to detect certain other forces, such as tilting and
shaking. In several computer games that employ accelerometers, players interface with the
system not by using a mouse or a keyboard but rather by tilting, rotating, and shaking the mobile
device! Perhaps more a practical use of these features is found in augmented-reality applications,
which overlay information on a display of the current environment. It is difficult to imagine how
equivalent applications could be developed on traditional laptop or desktop computer systems.
©zyBooks 10/20/22 18:14 1496583
To provide access to on-line services, mobile devices typically use eitherNoraisyah
IEEE standard 802.11
Abdl Aziz
AbdlAzizOSCOct2022
wireless or cellular data networks. The memory capacity and processing speed of mobile devices,
however, are more limited than those of PCs. Whereas a smartphone or tablet may have 256 GB in
storage, it is not uncommon to find 8 TB in storage on a desktop computer. Similarly, because
power consumption is such a concern, mobile devices often use processors that are smaller, are
slower, and offer fewer processing cores than processors found on traditional desktop and laptop
computers.
Two operating systems currently dominate mobile computing: Apple iOS and Google Android. iOS
was designed to run on Apple iPhone and iPad mobile devices. Android powers smartphones and
tablet computers available from many manufacturers. We examine these two mobile operating
systems in further detail in the next chapter Operating-System Structures.
Client-server computing
Server systems can be broadly categorized as compute servers and file servers:
The compute-server system provides an interface to which a client can send a request to
perform an action (for example, read data). In response, the server executes the action and
sends the results to the client. A server running a database that responds to client requests
for data is an example of such a system.
The file-server system provides a file-system interface where clients can create, update,
read, and delete files. An example of such a system is a web server that delivers files to
clients running web browsers. The actual contents of the files can vary greatly, ranging from
traditional web pages to rich multimedia content such as high-definition video.
Peer-to-peer computing
©zyBooks 10/20/22 18:14 1496583
Another structure for a distributed system is the peer-to-peer (P2P) system model.
Noraisyah In Aziz
Abdl this model,
clients and servers are not distinguished from one another. Instead, all AbdlAzizOSCOct2022
nodes within the system are
considered peers, and each may act as either a client or a server, depending on whether it is
requesting or providing a service. Peer-to-peer systems offer an advantage over traditional client-
server systems. In a client-server system, the server is a bottleneck; but in a peer-to-peer system,
services can be provided by several nodes distributed throughout the network.
To participate in a peer-to-peer system, a node must first join the network of peers. Once a node
has joined the network, it can begin providing services to—and requesting services from—other
nodes in the network. Determining what services are available is accomplished in one of two
general ways:
When a node joins a network, it registers its service with a centralized lookup service on the
network. Any node desiring a specific service first contacts this centralized lookup service to
determine which node provides the service. The remainder of the communication takes
place between the client and the service provider.
©zyBooksa 10/20/22
An alternative scheme uses no centralized lookup service. Instead, 18:14
peer acting as1496583
a client
Noraisyah Abdl Aziz
must discover what node provides a desired service by broadcasting a request for the
AbdlAzizOSCOct2022
service to all other nodes in the network. The node (or nodes) providing that service responds
to the peer making the request. To support this approach, a discovery protocol must be
provided that allows peers to discover services provided by other peers in the network. Figure
1.10.2 illustrates such a scenario.
Peer-to-peer networks gained widespread popularity in the late 1990s with several file-sharing
services, such as Napster and Gnutella, that enabled peers to exchange files with one another. The
Napster system used an approach similar to the first type described above: a centralized server
maintained an index of all files stored on peer nodes in the Napster network, and the actual
exchange of files took place between the peer nodes. The Gnutella system used a technique
similar to the second type: a client broadcast file requests to other nodes in the system, and nodes
©zyBooks 10/20/22
that could service the request responded directly to the client. Peer-to-peer networks18:14
can1496583
be used
Noraisyah Abdl Aziz
to exchange copyrighted materials (music, for example) anonymously,AbdlAzizOSCOct2022
and there are laws
governing the distribution of copyrighted material. Notably, Napster ran into legal trouble for
copyright infringement, and its services were shut down in 2001. For this reason, the future of
exchanging files remains uncertain.
Skype is another example of peer-to-peer computing. It allows clients to make voice calls and
video calls and to send text messages over the Internet using a technology known as voice over IP
(VoIP). Skype uses a hybrid peer-to-peer approach. It includes a centralized login server, but it also
incorporates decentralized peers and allows two peers to communicate.
Cloud computing
Cloud computing is a type of computing that delivers computing, storage, and even applications as
a service across a network. In some ways, it's a logical extension of virtualization, because it uses
virtualization as a base for its functionality. For example, the Amazon Elastic
©zyBooks Compute
10/20/22 18:14Cloud (ec2)
1496583
Noraisyah
facility has thousands of servers, millions of virtual machines, and petabytes Abdl Aziz
of storage available
AbdlAzizOSCOct2022
for use by anyone on the Internet. Users pay per month based on how much of those resources
they use. There are actually many types of cloud computing, including the following:
Public cloud—a cloud available via the Internet to anyone willing to pay for the services
Private cloud—a cloud run by a company for that company's own use
Hybrid cloud—a cloud that includes both public and private cloud components
Platform as a service (PaaS)—a software stack ready for application use via the Internet (for
example, a database server)
Infrastructure as a service (IaaS)—servers or storage available over the Internet (for example,
storage available for making backup copies of production data)
These cloud-computing types are not discrete, as a cloud computing environment may provide a
combination of several types. For example, an organization may provide both SaaS and IaaS as
publicly available services.
Certainly, there are traditional operating systems within many of the types of cloud infrastructure.
Beyond those are the VMMs that manage the virtual machines in which the user processes run. At
a higher level, the VMMs themselves are managed by cloud management tools, such as VMware
vCloud Director and the open-source Eucalyptus toolset. These tools manage the resources within
a given cloud and provide interfaces to the cloud components, making a good argument for
considering them a new type of operating system.
Figure 1.10.3 illustrates a public cloud providing IaaS. Notice that both the cloud services and the
cloud user interface are protected by a firewall.
Embedded computers are the most prevalent form of computers in existence. These devices are
found everywhere, from car engines and manufacturing robots to optical drives and microwave
ovens. They tend to have very specific tasks. The systems they run on are usually primitive, and so
the operating systems provide limited features. Usually, they have little or no user interface,
preferring to spend their time monitoring and managing hardware devices, such as automobile
engines and robotic arms.
These embedded systems vary considerably. Some are general-purpose computers, running
standard operating systems—such as Linux—with special-purpose applications to implement the
functionality. Others are hardware devices with a special-purpose embedded operating system
providing just the functionality desired. Yet others are hardware devices with application-specific
integrated circuits (ASICs) that perform their tasks without an operating system.
The use of embedded systems continues to expand. The power of these devices, both as
standalone units and as elements of networks and the web, is sure to increase
©zyBooks as well.
10/20/22 18:14Even now,
1496583
Noraisyah Abdl Aziz
entire houses can be computerized, so that a central computer—either a general-purpose
AbdlAzizOSCOct2022
computer or an embedded system—can control heating and lighting, alarm systems, and even
coffee makers. Web access can enable a home owner to tell the house to heat up before she
arrives home. Someday, the refrigerator will be able to notify the grocery store when it notices the
milk is gone.
Embedded systems almost always run real-time operating systems. A real-time system is used
when rigid time requirements have been placed on the operation of a processor or the flow of data;
thus, it is often used as a control device in a dedicated application. Sensors bring data to the
computer. The computer must analyze the data and possibly adjust controls to modify the sensor
inputs. Systems that control scientific experiments, medical imaging systems, industrial control
systems, and certain display systems are real-time systems. Some automobile-engine fuel-
injection systems, home-appliance controllers, and weapon systems are also real-time systems.
A real-time system has well-defined, fixed time constraints. Processing must be done within the
defined constraints, or the system will fail. For instance, it would not do for a robot arm to be
©zyBooks 10/20/22 18:14 1496583
instructed to halt after it had smashed into the car it was building. A real-time system
Noraisyah functions
Abdl Aziz
AbdlAzizOSCOct2022
correctly only if it returns the correct result within its time constraints. Contrast this system with a
traditional laptop system where it is desirable (but not mandatory) to respond quickly.
In the chapter CPU Scheduling, we consider the scheduling facility needed to implement real-time
functionality in an operating system, and in the chapter The Linux System, we describe the real-
time components of Linux.
PARTICIPATION
ACTIVITY
1.10.1: Section review questions.
Section glossary
server system: A system providing services to other computers (e.g., a web server).
client system: A computer that uses services from other computers (such as a
web client).
public cloud: Cloud computing available via the Internet to anyone willing
©zyBooks to pay
10/20/22 for1496583
18:14
the services offered. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
private cloud: Cloud computing run by a company for that company's own use.
hybrid cloud: A type of cloud computing that includes both public and private cloud
components.
Software as a Service (SaaS): A type of computing in which one or more
applications (such as word processors or spreadsheets) are available as a service
via the Internet.
platform as a service (PaaS): A software stack ready for application use via the
Internet (e.g., a database server).
infrastructure as a service (IaaS): A type of computing in which servers or storage
are available over the Internet (e.g, storage available for making backup copies of
production data).
real-time operating systems (RTOS): Systems used when rigid time requirements
have been placed on the operation of a processor or the flow of data; often used as
control devices in dedicated applications.
Starting with the source code allows the programmer to produce binary code that can be executed
on a system. Doing the opposite—reverse engineering the source code from the binaries—is quite
a lot of work, and useful items such as comments are never recovered. Learning operating
systems by examining the source code has other benefits as well. With the source code in hand, a
©zyBooks 10/20/22 18:14 1496583
student can modify the operating system and then compile and run theNoraisyah
code to try outAziz
Abdl those
changes, which is an excellent learning tool. This text includes projectsAbdlAzizOSCOct2022
that involve modifying
operating-system source code, while also describing algorithms at a high level to be sure all
important operating-system topics are covered. Throughout the text, we provide pointers to
examples of open-source code for deeper study.
There are many benefits to open-source operating systems, including a community of interested
(and usually unpaid) programmers who contribute to the code by helping to write it, debug it,
analyze it, provide support, and suggest changes. Arguably, open-source code is more secure than
closed-source code because many more eyes are viewing the code. Certainly, open-source code
has bugs, but open-source advocates argue that bugs tend to be found and fixed faster owing to
the number of people using and viewing the code. Companies that earn revenue from selling their
programs often hesitate to open-source their code, but Red Hat and a myriad of other companies
are doing just that and showing that commercial companies benefit, rather than suffer, when they
open-source their code. Revenue can be generated through support contracts and the sale of
hardware on which the software runs, for example.
History
In the early days of modern computing (that is, the 1950s), software generally came with source
code. The original hackers (computer enthusiasts) at MIT's Tech Model Railroad Club left their
programs in drawers for others to work on. "Homebrew" user groups exchanged code during their
meetings. Company-specific user groups, such as Digital Equipment Corporation's DECUS,
accepted contributions of source-code programs, collected them onto tapes, and distributed the
tapes to interested members. In 1970, Digital's operating systems were distributed as source code
with no restrictions or copyright notice.
Computer and software companies eventually sought to limit the use of their software to
authorized computers and paying customers. Releasing only the binary files compiled from the
source code, rather than the source code itself, helped them to achieve this goal, as well as
protecting their code and their ideas from their competitors. Although the Homebrew user groups
of the 1970s exchanged code during their meetings, the operating systems10/20/22
©zyBooks for hobbyist
18:14 machines
1496583
(such as CPM) were proprietary. By 1980, proprietary software was the Noraisyah
usual case.
Abdl Aziz
AbdlAzizOSCOct2022
To counter the move to limit software use and redistribution, Richard Stallman in 1984 started
developing a free, UNIX-compatible operating system called GNU (which is a recursive acronym for
"GNU's Not Unix!"). To Stallman, "free" refers to freedom of use, not price. The free-software
movement does not object to trading a copy for an amount of money but holds that users are
entitled to four certain freedoms: (1) to freely run the program, (2) to study and change the source
code, and to give or sell copies either (3) with or (4) without changes. In 1985, Stallman published
the GNU Manifesto, which argues that all software should be free. He also formed the Free
Software Foundation (FSF) with the goal of encouraging the use and development of free software.
The FSF uses the copyrights on its programs to implement "copyleft," a form of licensing invented
by Stallman. Copylefting a work gives anyone that possesses a copy of the work the four essential
freedoms that make the work free, with the condition that redistribution must preserve these
©zyBooks 10/20/22 18:14 1496583
freedoms. The GNU General Public License (GPL) is a common licenseNoraisyah
under which
Abdlfree
Azizsoftware
AbdlAzizOSCOct2022
is released. Fundamentally, the GPL requires that the source code be distributed with any binaries
and that all copies (including modified versions) be released under the same GPL license. The
Creative Commons "Attribution Sharealike" license is also a copyleft license; "sharealike" is another
way of stating the idea of copyleft.
GNU/linux
As an example of a free and open-source operating system, consider GNU/Linux. By 1991, the GNU
operating system was nearly complete. The GNU Project had developed compilers, editors, utilities,
libraries, and games—whatever parts it could not find elsewhere. However, the GNU kernel never
became ready for prime time. In 1991, a student in Finland, Linus Torvalds, released a rudimentary
UNIX-like kernel using the GNU compilers and tools and invited contributions worldwide. The
advent of the Internet meant that anyone interested could download the source code, modify it,
and submit changes to Torvalds. Releasing updates once a week allowed this so-called "Linux"
operating system to grow rapidly, enhanced by several thousand programmers. In 1991, Linux was
not free software, as its license permitted only noncommercial redistribution. In 1992, however,
Torvalds rereleased Linux under the GPL, making it free software (and also, to use a term coined
later, "open source").
The resulting GNU/Linux operating system (with the kernel properly called Linux but the full
operating system including GNU tools called GNU/Linux) has spawned hundreds of unique
distributions, or custom builds, of the system. Major distributions include Red Hat, SUSE, Fedora,
Debian, Slackware, and Ubuntu. Distributions vary in function, utility, installed applications,
hardware support, user interface, and purpose. For example, Red Hat Enterprise Linux is geared to
large commercial use. PCLinuxOS is a live CD—an operating system that can be booted and run
from a CD-ROM without being installed on a system's boot disk. A variant of PCLOS—called PCLOS
Supergamer DVD—is a live DVD that includes graphics drivers and games. A gamer can run it on
any compatible system simply by booting from the DVD. When the gamer is finished, a reboot of
the system resets it to its installed operating system.
You can run Linux on a Windows (or other) system using the following simple,
©zyBooks free 18:14
10/20/22 approach:
1496583
Noraisyah Abdl Aziz
1. Download the free Virtualbox VMM tool from https://www.virtualbox.org/ and install it on
AbdlAzizOSCOct2022
your system.
2. Choose to install an operating system from scratch, based on an installation image like a CD,
or choose pre-built operating-system images that can be installed and run more quickly from
a site like http://virtualboxes.org/images/. These images are preinstalled with operating
systems and applications and include many flavors of GNU/Linux.
3. Boot the virtual machine within Virtualbox.
An alternative to using Virtualbox is to use the free program Qemu
(http://wiki.qemu.org/Download/), which includes the qemu-img command for converting
Virtualbox images to Qemu images to easily import them.
With this text, we provide a virtual machine image of GNU/Linux running the Ubuntu release. This
image contains the GNU/Linux source code as well as tools for software development. We cover
examples involving the GNU/Linux image throughout this text, as well as in a detailed case study in
the chapter The Linux System.
©zyBooks 10/20/22 18:14 1496583
Noraisyah Abdl Aziz
BSD unix AbdlAzizOSCOct2022
BSD UNIX has a longer and more complicated history than Linux. It started in 1978 as a derivative
of AT&T's UNIX. Releases from the University of California at Berkeley (UCB) came in source and
binary form, but they were not open source because a license from AT&T was required. BSD UNIX's
development was slowed by a lawsuit by AT&T, but eventually a fully functional, open-source
version, 4.4BSD-lite, was released in 1994.
Just as with Linux, there are many distributions of BSD UNIX, including FreeBSD, NetBSD,
OpenBSD, and DragonflyBSD. To explore the source code of FreeBSD, simply download the virtual
machine image of the version of interest and boot it within Virtualbox, as described above for
Linux. The source code comes with the distribution and is stored in /usr/src/. The kernel source
code is in /usr/src/sys. For example, to examine the virtual memory implementation code in the
FreeBSD kernel, see the files in /usr/src/sys/vm. Alternatively, you can simply view the source
code online at https://svnweb.freebsd.org.
As with many open-source projects, this source code is contained in and controlled by a version
control system—in this case, "subversion" (https://subversion.apache.org/source-code). Version
control systems allow a user to "pull" an entire source code tree to his computer and "push" any
changes back into the repository for others to then pull. These systems also provide other features,
including an entire history of each file and a conflict resolution feature in case the same file is
changed concurrently. Another version control system is git, which is used for GNU/Linux, as well
as other programs (http://www.git-scm.com).
Darwin, the core kernel component of macOS, is based on BSD UNIX and is open-sourced as well.
That source code is available from http://www.opensource.apple.com/. Every macOS release has
its open-source components posted at that site. The name of the package that contains the kernel
begins with "xnu." Apple also provides extensive developer tools, documentation, and support at
http://developer.apple.com.
There has never been a more interesting time to study operating systems, and it
has never been easier. The open-source movement has overtaken operating
systems, causing many of them to be made available in both source and binary
(executable) format. The list of operating systems available in both formats
includes Linux, BSD UNIX, Solaris, and part of macOS. The availability of source
code allows us to study operating systems from the inside out. Questions that we
could once answer only by looking at documentation or the behavior of an
operating system we can now answer by examining the code itself.
Operating systems that are no longer commercially viable have been open-sourced
as well, enabling us to study how systems operated in a time of fewer CPU,
memory, and storage resources. An extensive but incomplete list of open-source
operating-system projects is available from
http://dmoz.org/Computers/Software/Operating_Systems/Open_Source/.
©zyBooks 10/20/22 18:14 1496583
Noraisyah
In addition, the rise of virtualization as a mainstream (and frequently free) Abdl Aziz
AbdlAzizOSCOct2022
computer function makes it possible to run many operating systems on top of one
core system. For example, VMware (http://www.vmware.com) provides a free
"player" for Windows on which hundreds of free "virtual appliances" can run.
Virtualbox (http://www.virtualbox.com) provides a free, open-source virtual
machine manager on many operating systems. Using such tools, students can try
out hundreds of operating systems without dedicated hardware.
In some cases, simulators of specific hardware are also available, allowing the
operating system to run on "native" hardware, all within the confines of a modern
computer and modern operating system. For example, a DECSYSTEM-20 simulator
running on macOS can boot TOPS-20, load the source tapes, and modify and
compile a new TOPS-20 kernel. An interested student can search the Internet to
find the original papers that describe the operating system, as well as the original
manuals.
The advent of open-source operating systems has also made it easier to make the
move from student to operating-system developer. With some knowledge, some
effort, and an Internet connection, a student can even create a new operating-
system distribution. Not so many years ago, it was difficult or impossible to get
access to source code. Now, such access is limited only by how much interest,
time, and disk space a student has.
Solaris
Solaris is the commercial UNIX-based operating system of Sun Microsystems. Originally, Sun's
SunOS operating system was based on BSD UNIX. Sun moved to AT&T's System V UNIX as its
base in 1991. In 2005, Sun open-sourced most of the Solaris code as the OpenSolaris project. The
purchase of Sun by Oracle in 2009, however, left the state of this ©zyBooks 10/20/22 18:14 1496583
project unclear.
Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
Several groups interested in using OpenSolaris have expanded its features, and their working set is
Project Illumos, which has expanded from the OpenSolaris base to include more features and to be
the basis for several products. Illumos is available at http://wiki.illumos.org.
PARTICIPATION
ACTIVITY
1.11.1: Section review questions.
free operating system: An operating system released under a license that makes
its source code available and allows no-cost use, redistribution, and modification.
LiveCD: An operating system that can be booted and run from a CD-ROM (or more
generally from any media) without being installed on a system's boot disk(s).
LiveDVD: An operating system that can be booted and run from a DVD (or more
generally from any media) without being installed on a system's boot disk(s).
UnixBSD: A UNIX derivative based on work done at the University of California at
Berkeley (UCB).
version control system: Software that manages software distributions by allowing
contributors to "push" changes into a repository and "pull" a version of the software
source-code tree to a system (e.g., for compilation).
git: A version control system used for GNU/Linux and other programs.
Solaris: A UNIX derivative that is the main operating system of Sun Microsystems
(now owned by Oracle Corporation). There is an active open source version called
Illumos.
©zyBooks 10/20/22 18:14 1496583
SunOS: The predecessor of Solaris by Sun Microsystems Inc. Noraisyah Abdl Aziz
AbdlAzizOSCOct2022
1.12 Summary
An operating system is software that manages the computer hardware, as well as providing
an environment for application programs to run.
Interrupts are a key way in which hardware interacts with the operating system. A hardware
device triggers an interrupt by sending a signal to the CPU to alert the CPU that some event
requires attention. The interrupt is managed by the interrupt handler.
For a computer to do its job of executing programs, the programs must be in main memory,
which is the only large storage area that the processor can ©zyBooks 10/20/22 18:14 1496583
access directly.
Noraisyah Abdl Aziz
The main memory is usually a volatile storage device that loses its contents when power is
AbdlAzizOSCOct2022
turned off or lost.
Nonvolatile storage is an extension of main memory and is capable of holding large
quantities of data permanently.
The most common nonvolatile storage device is a hard disk, which can provide storage of
both programs and data.
The wide variety of storage systems in a computer system can be organized in a hierarchy
according to speed and cost. The higher levels are expensive, but they are fast. As we move
down the hierarchy, the cost per bit generally decreases, whereas the access time generally
increases.
Modern computer architectures are multiprocessor systems in which each CPU contains
several computing cores.
To best utilize the CPU, modern operating systems employ multiprogramming, which allows
several jobs to be in memory at the same time, thus ensuring that the CPU always has a job
to execute.
Multitasking is an extension of multiprogramming wherein CPU scheduling algorithms
rapidly switch between processes, providing users with a fast response time.
To prevent user programs from interfering with the proper operation of the system, the
system hardware has two modes: user mode and kernel mode.
Various instructions are privileged and can be executed only in kernel mode. Examples
include the instruction to switch to kernel mode, I/O control, timer management, and
interrupt management.
A process is the fundamental unit of work in an operating system. Process management
includes creating and deleting processes and providing mechanisms for processes to
communicate and synchronize with each other.
An operating system manages memory by keeping track of what parts of memory are being
used and by whom. It is also responsible for dynamically allocating and freeing memory
space.
Storage space is managed by the operating system; this includes providing file systems for
representing files and directories and managing space on mass-storage devices.
©zyBooks 10/20/22 18:14 1496583
Operating systems provide mechanisms for protecting and securing the operating
Noraisyah Abdl Azizsystem
AbdlAzizOSCOct2022
and users. Protection measures control the access of processes or users to the resources
made available by the computer system.
Virtualization involves abstracting a computer's hardware into several different execution
environments.
Data structures that are used in an operating system include lists, stacks, queues, trees, and
maps.
Computing takes place in a variety of environments, including traditional computing, mobile
computing, client-server systems, peer-to-peer systems, cloud computing, and real-time
embedded systems.
Free and open-source operating systems are available in source-code format. Free software
is licensed to allow no-cost use, redistribution, and modification. GNU/Linux, FreeBSD, and
Solaris are examples of popular open-source systems.
1.14 Exercises
(b) How does the CPU know when the memory operations are complete?
(c) The CPU is allowed to execute other programs while the DMA controller is
transferring data. Does this process interfere with the execution of the user
programs? If so, describe what forms of interference are caused.
a. Hard-disk drives
b. Registers
c. Optical disk
d. Main memory
e. Nonvolatile memory
f. Magnetic tapes
g. Cache
(c) A neighborhood
(a)
Describe some of the challenges of designing operating systems for mobile devices
compared with designing operating systems for traditional PCs.
1.16 Bibliography
[Hennessy and Patterson (2012)] J. Hennessy and D. Patterson, Computer Architecture: A
Quantitative Approach, Fifth Edition, Morgan Kaufmann (2012).
[Kurose and Ross (2017)] J. Kurose and K. Ross, Computer Networking—A Top-Down Approach,
Seventh Edition, Addison-Wesley (2017).
[Levin (2013)] J. Levin, Mac OS X and iOS Internals to the Apple's Core, Wiley (2013).