Unit I - Chapter 1
Unit I - Chapter 1
Operating System Concepts – 10h Edition Silberschatz, Galvin and Gagne ©2018
Outline
1.1 What Operating Systems Do 1.4 Operating-System Operations
• 1.1.1 User View • 1.4.1 Multiprogramming and
• 1.1.2 System View Multitasking
• 1.1.3 Defining Operating Systems • 1.4.2 Dual-Mode and Multimode
Operation
1.2 Computer-System
• 1.4.3 Timer
Organization
1.5 Resource Management
• 1.2.1 Interrupts
1.2.1.1 Overview
• 1.5.1 Process Management
1.2.1.2 Implementation
• 1.5.2 Memory Management
Operating System Concepts – 10th Edition 1.2 Silberschatz, Galvin and Gagne ©2018
Introduction
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.
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.
It is important first to understand the organization and architecture of
computer hardware.
This includes the CPU, memory, and I/O devices, as well as storage.
A fundamental responsibility of an operating system is to allocate these
resources to programs.
Because an operating system is large and complex, it must be created piece
by piece.
Each of these pieces should be a well-described portion of the system, with
carefully defined inputs, outputs, and functions.
Operating System Concepts – 10th Edition 1.3 Silberschatz, Galvin and Gagne ©2018
1.1 What Operating Systems Do
A computer system can be divided into four components: the
hardware, the operating system, the application programs, and a user (
Figure 1.1).
• Hardware – The central processing unit (CPU), the memory, and
the input/output (I/O) devices—provides the basic computing
resources for the system.
• Operating system – Controls the hardware and coordinates its use
among the various application programs for the various users. It
simply provides an environment within which other programs can
do useful work.
• 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.
• Users —People, machines, other computers.
Operating System Concepts – 10th Edition 1.4 Silberschatz, Galvin and Gagne ©2018
Abstract View of Components of Computer
Figure 1.1
BACK
Operating System Concepts – 10th Edition 1.5 Silberschatz, Galvin and Gagne ©2018
1.1.1 User View
Users want convenience, ease of use and good performance, but don’t
care about resource utilization.
But shared computer such as mainframe or minicomputer must keep all
users happy.
Users of dedicate systems such as workstations have dedicated resources
but frequently use shared resources from servers.
Increasingly, many users interact with mobile devices such as smart phones
and tablets—devices 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.
Operating System Concepts – 10th Edition 1.6 Silberschatz, Galvin and Gagne ©2018
1.1.2 System View
From the computer’s point of view, the operating system is the program most
closely involved with the hardware.
In this context, we can view an operating system as a resource allocator.
A 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, 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.
Operating System Concepts – 10th Edition 1.7 Silberschatz, Galvin and Gagne ©2018
1.1.3 Defining Operating Systems
Definition:-
• A program that acts as an intermediary between a user of a computer
and the computer hardware.
• A more common definition, is that the operating system is the one
program running at all times on the computer—usually called the
kernel.
Operating System Concepts – 10th Edition 1.8 Silberschatz, Galvin and Gagne ©2018
1.1.3 Defining Operating Systems (Cont)
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.
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.
Operating System Concepts – 10th Edition 1.9 Silberschatz, Galvin and Gagne ©2018
1.2 Computer-System Organization
Computer-system operation
• General-purpose computer system consists of one or more CPUs
and a number of device controllers connected through a common
bus that provides access between components and shared memory
(Figure 1.2).
• Each device controller is in charge of a specific type of device (for
example, a disk drive, audio device, or graphics display).
• Depending on the controller, more than one device may be
attached.
• For instance, one system USB port can connect to a USB hub, to
which several devices can connect.
• A device controller maintains some local buffer storage and a set of
special-purpose registers.
• The device controller is responsible for moving the data between the
peripheral devices that it controls and its local buffer storage.
Operating System Concepts – 10th Edition 1.10 Silberschatz, Galvin and Gagne ©2018
1.2 Computer-System Organization (Cont.)
• 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.
• Device controller informs CPU that it has finished its operation by
causing an interrupt.
Operating System Concepts – 10th Edition 1.11 Silberschatz, Galvin and Gagne ©2018
A typical PC computer system.
Figure 1.2
BACK
Operating System Concepts – 10th Edition 1.12 Silberschatz, Galvin and Gagne ©2018
1.2.1 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.
But how does the controller inform the device driver that it has finished its
operation? This is accomplished via an interrupt.
Operating System Concepts – 10th Edition 1.13 Silberschatz, Galvin and Gagne ©2018
1.2.1.1 Overview
An interrupt is a signal from a device attached to a computer or from a
program within the computer that requires the operating system to stop and
figure out what to do next.
There are two types of interrupts which are as follows −
1. Hardware interrupts
• The interrupt signal generated from external devices and i/o devices are
made interrupt to CPU when the instructions are ready.
• For example − In a keyboard if we press a key to do some action this
pressing of the keyboard generates a signal that is given to the processor
to do action, such interrupts are called hardware interrupts.
2. Software interrupts
• The interrupt signal generated from internal devices and software
programs need to access any system call then software interrupts are
present.
• For example − while executing a program if we got a value that is
divided by zero is called an exception.
Hardware may trigger an interrupt at any time by sending a signal to the
CPU, usually by way of the system bus.
Operating System Concepts – 10th Edition 1.14 Silberschatz, Galvin and Gagne ©2018
1.2.1.2 Implementation
The basic interrupt mechanism works as follows.
The CPU hardware has a wire called the interrupt-request line that the
CPU senses after executing every instruction.
When the CPU detects that a controller has a signal on the interrupt-request
line, it reads the interrupt number and jumps to the interrupt-handler
routine by using that interrupt number as an index into the interrupt vector.
It then starts execution at the address associated with that index.
The interrupt handler saves any state it will be changing during its operation,
determines the cause of the interrupt, performs the necessary processing,
performs a state restore, and executes a return from interrupt instruction to
return the CPU to the execution state prior to the interrupt.
We say that the device controller raises an interrupt by a signal on the
interrupt request line, the CPU catches the interrupt and dispatches it to the
interrupt handler, and the handler clears the interrupt by servicing the device.
Figure 1.3 summarizes the interrupt-driven I/O cycle.
Operating System Concepts – 10th Edition 1.15 Silberschatz, Galvin and Gagne ©2018
1.2.1.2 Implementation (Cont.)
Sophisticated interrupt handling features:-
1. We need an efficient way to dispatch to the proper interrupt handler for a
device.
2. We need the ability to defer interrupt handling during critical processing.
3. We need multilevel interrupts, so that the operating system can
distinguish between high- and low-priority interrupts and can respond
with the appropriate degree of urgency.
In modern computer hardware, these three features are provided by the
CPU and the interrupt-controller hardware.
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.
Operating System Concepts – 10th Edition 1.16 Silberschatz, Galvin and Gagne ©2018
1.2.1.2 Implementation (Cont.)
The maskable interrupt is used by device controllers to request service.
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.
Figure 1.4 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
and high-priority interrupt.
Operating System Concepts – 10th Edition 1.17 Silberschatz, Galvin and Gagne ©2018
Interrupt-driven I/O cycle.
BACK
BACK
Operating System Concepts – 10th Edition 1.20 Silberschatz, Galvin and Gagne ©2018
1.2.2 Storage Structure (Cont.)
Ideally, we want the programs and data to reside in main memory
permanently. It is not possible on most systems for two reasons:
1. Main memory is usually too small to store all needed programs and
data permanently.
2. Main memory, as mentioned, is volatile—it loses its contents when
power is turned off or otherwise lost.
Thus, most computer systems provide secondary storage as an
extension of main memory.
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.
Operating System Concepts – 10th Edition 1.21 Silberschatz, Galvin and Gagne ©2018
1.2.2 Storage Structure (Cont.)
Secondary storage is also much slower than main memory.
Hence, the proper management of secondary storage is of central
importance to a computer system.
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.
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.5) according to storage capacity and access time.
In general, we will use the following terminology:
Operating System Concepts – 10th Edition 1.22 Silberschatz, Galvin and Gagne ©2018
1.2.2 Storage Structure (Cont.)
Volatile storage will be referred to simply as memory, loses its
contents when the power to the device is removed
Nonvolatile storage retains its contents when power is lost. It will be
referred to as NVS.
NVS type of storage can be classified into two distinct types:
• Mechanical. A few examples of such storage systems are HDDs,
optical disks, holographic storage, and magnetic tape.
• Electrical. A few examples of such storage systems are flash
memory, FRAM, NRAM, and SSD.
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.
Operating System Concepts – 10th Edition 1.23 Silberschatz, Galvin and Gagne ©2018
Storage-device hierarchy
Operating System Concepts – 10th Edition 1.25 Silberschatz, Galvin and Gagne ©2018
How a modern computer system works
BACK
Figure 1.6
Operating System Concepts – 10th Edition 1.26 Silberschatz, Galvin and Gagne ©2018
1.3 Computer-System Architecture
A computer system can be organized in a number of different ways, which we
can categorize roughly according to the number of general-purpose processors
used.
• 1.3.1 Single-Processor Systems
If there is only one general-purpose CPU with a single processing core,
then the system is a single-processor system.
• 1.3.2 Multiprocessor Systems (Chapter 2)
Multiprocessors systems growing in use and importance, such
systems have two (or more) processors, each with a single-core CPU.
Also known as parallel systems, tightly-coupled systems.
• 1.3.3 Clustered Systems (chapter 2)
Another type of multiprocessor system is a clustered system, which
gathers together multiple CPUs. Clustered systems differ from the
multiprocessor systems in that they are composed of two or more
individual systems—or nodes—joined together; each node is typically a
multicore system.
Operating System Concepts – 10th Edition 1.27 Silberschatz, Galvin and Gagne ©2018
1.3.1 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,
Operating System Concepts – 10th Edition 1.28 Silberschatz, Galvin and Gagne ©2018
1.3.1 Single-Processor Systems (Cont.)
PCs contain a microprocessor in the keyboard to convert 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.
Operating System Concepts – 10th Edition 1.29 Silberschatz, Galvin and Gagne ©2018
1.4 Operating-System Operations
For a computer to start running— for instance, when it is powered up or
rebooted—it needs to have an initial program to run.
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.
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.
Operating System Concepts – 10th Edition 1.30 Silberschatz, Galvin and Gagne ©2018
1.4 Operating-System Operations (Cont.)
Operating System Concepts – 10th Edition 1.31 Silberschatz, Galvin and Gagne ©2018
1.4.1 Multiprogramming and Multitasking
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 multi programmed 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.7).
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.
Operating System Concepts – 10th Edition 1.32 Silberschatz, Galvin and Gagne ©2018
Memory layout for a multiprogramming system
Operating System Concepts – 10th Edition 1.33 Silberschatz, Galvin and Gagne ©2018
1.4.1 Multiprogramming and Multitasking (Cont.)
Operating System Concepts – 10th Edition 1.34 Silberschatz, Galvin and Gagne ©2018
1.4.1 Multiprogramming and Multitasking(Cont.)
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.
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.
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.
The main advantage of this scheme is that it enables users to run programs
that are larger than actual physical memory.
Operating System Concepts – 10th Edition 1.35 Silberschatz, Galvin and Gagne ©2018
1.4.2 Dual-Mode and Multimode Operation
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.
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.8.
Operating System Concepts – 10th Edition 1.36 Silberschatz, Galvin and Gagne ©2018
1.4.2 Dual-Mode and Multimode Operation (Cont.)
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 misbehaving users.
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.
Operating System Concepts – 10th Edition 1.37 Silberschatz, Galvin and Gagne ©2018
1.4.2 Dual-Mode and Multimode Operation (Cont.)
Examples include I/O control, timer management, and interrupt
management.
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 call.
Most operating systems—such as Microsoft Windows, Unix, and Linux—
take advantage of this dual-mode feature and provide greater protection for
the operating system.
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.
Operating System Concepts – 10th Edition 1.38 Silberschatz, Galvin and Gagne ©2018
Transition from User to Kernel Mode
Figure 1.8
BACK
Operating System Concepts – 10th Edition 1.39 Silberschatz, Galvin and Gagne ©2018
1.4.3 Timer
Operating system 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, uses 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.
Clearly, instructions that modify the content of the timer are privileged.
Operating System Concepts – 10th Edition 1.40 Silberschatz, Galvin and Gagne ©2018
1.5 Resource Management
An operating system is a resource manager.
The system’s CPU, memory space, file-storage space, and I/O devices
are among the resources that the operating system must manage.
Operating System Concepts – 10th Edition 1.41 Silberschatz, Galvin and Gagne ©2018
1.5.1 Process Management
A program can do nothing unless its instructions are executed by a CPU.
A program in execution is 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 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.
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 and system calls to obtain and display the desired information on
the screen.
When the process terminates, the operating system will reclaim any reusable
resources.
Operating System Concepts – 10th Edition 1.42 Silberschatz, Galvin and Gagne ©2018
1.5.1 Process Management (Cont.)
A single-threaded process has one program counter specifying the next
instruction to execute.
Operating System Concepts – 10th Edition 1.43 Silberschatz, Galvin and Gagne ©2018
1.5.2 Memory Management
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.
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.
Operating System Concepts – 10th Edition 1.44 Silberschatz, Galvin and Gagne ©2018
1.5.2 Memory Management (Cont.)
As the program executes, it accesses program instructions and data from
memory by generating these absolute addresses.
Operating System Concepts – 10th Edition 1.45 Silberschatz, Galvin and Gagne ©2018
1.5.3 File-System Management
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).
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 freeform (for example, text files), or they may be formatted
rigidly (for example, fixed fields such as an mp3 music file).
Operating System Concepts – 10th Edition 1.46 Silberschatz, Galvin and Gagne ©2018
1.5.3 File-System Management(Cont.)
The operating system implements the abstract concept of a file by
managing mass storage media and the devices that control them.
Operating System Concepts – 10th Edition 1.47 Silberschatz, Galvin and Gagne ©2018
1.5.4 Mass-Storage Management
Secondary storage is used frequently and extensively, it must be used efficiently.
The entire speed of operation of a computer may turning point on the speeds of
the secondary storage subsystem and the algorithms that manipulate that
subsystem.
Backups of disk data, storage of rarely-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
The operating system is responsible for the following activities in connection
with secondary storage management:
• Mounting and unmounting
• Free-space management
• Storage allocation
• Disk scheduling
• Partitioning
• Protection
Operating System Concepts – 10th Edition 1.48 Silberschatz, Galvin and Gagne ©2018
1.5.5 Cache Management
Caching is an important principle of computer systems.
How it works.:
Information is normally kept in some storage system (such as main
memory). As it is used, it is copied into a faster storage system— the cache
—on a temporary basis.
When we need a particular piece of information, we first check whether it is
in the cache. If it is, we use the information directly from the cache.
If it is not, we use the information from the source, putting a copy in the
cache under the assumption that we will need it again soon.
In addition, internal programmable registers provide a high-speed cache
for main memory.
The compiler implements the register allocation and register-replacement
algorithms to decide which information to keep in registers and which to keep
in main 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.
Operating System Concepts – 10th Edition 1.49 Silberschatz, Galvin and Gagne ©2018
1.5.5 Cache Management (Cont.)
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 (Figure 1.9).
Once the increment takes place in the internal register, the value of A differs
in the various storage systems.
Operating System Concepts – 10th Edition 1.50 Silberschatz, Galvin and Gagne ©2018
1.5.5 Cache Management (Cont.)
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.
The situation becomes more complicated in a multiprocessor
environment where, in addition to maintaining internal registers, each of
the CPUs also contains a local cache.
In such an environment, a copy of A may exist simultaneously in
several caches.
Since the various CPUs can all execute in parallel, we must make sure
that an update to the value of A in one cache is immediately reflected in
all other caches where A resides. This situation is called cache
coherency, and it is usually a hardware issue.
Operating System Concepts – 10th Edition 1.51 Silberschatz, Galvin and Gagne ©2018
Migration of integer “A” from disk to register
Figure 1.9
BACK
Operating System Concepts – 10th Edition 1.52 Silberschatz, Galvin and Gagne ©2018
1.5.6 I/O System Management
One of the purposes of an operating system is to hide the peculiarities of
specific hardware devices from the user.
Operating System Concepts – 10th Edition 1.53 Silberschatz, Galvin and Gagne ©2018
1.6 Security and Protection
If a computer system has multiple users and allows the concurrent
execution of multiple processes, then access to data must be regulated.
For that purpose, mechanisms ensure that files, memory segments, CPU,
and other resources can be operated on by only those processes that have
gained proper authorization from the operating system.
Protection, is any mechanism for controlling the access of processes or
users to the resources defined by a computer system. This mechanism
must provide means to specify the controls to be imposed and to enforce
the controls.
Protection can improve reliability by detecting latent errors at the interfaces
between component subsystems.
A system can have adequate protection but still be prone to failure and
allow inappropriate access.
It is the job of security to defend a system from external and internal
attacks.
Operating System Concepts – 10th Edition 1.54 Silberschatz, Galvin and Gagne ©2018
1.6 Security and Protection(Cont.)
Such attacks spread across a huge range and include viruses and worms,
denial-of service attacks (which use all of a system’s resources and so keep
legitimate users out of the system), identity theft, and theft of service
(unauthorized use of a system).
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
identifier (user IDs). In Windows, 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.
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.
Operating System Concepts – 10th Edition 1.55 Silberschatz, Galvin and Gagne ©2018
1.6 Security and Protection (Cont.)
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 identifier.
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.
Operating System Concepts – 10th Edition 1.56 Silberschatz, Galvin and Gagne ©2018
End of Chapter 1
Operating System Concepts – 10h Edition Silberschatz, Galvin and Gagne ©2018