Operatin
g
Systems: Chapter 2
Internals
and Operating
Design System Overview
Principle Eighth Edition
Global Edition
s By William Stallings
Operating System
A program that controls the execution of
application programs
Aninterface between applications and
hardware
Main objectives
of an OS:
•
convenience
•
efficiency
•
ability to evolve
Operating System
Services
Program development
Program execution
Access I/O devices
Controlled access to files
System access
Error detection and response
Accounting
OS Services
Accounting
collectstatistics
monitor performance
used to anticipate future
enhancements
used for billing users
Key Interfaces
Instruction set architecture (ISA)
Application binary interface (ABI)
Application programming interface
(API)
The Role of an OS
A computer is a set of resources
for the movement, storage, and
processing of data
TheOS is responsible for managing
these resources
Operating System
as Software
Functionsin the same way as
ordinary computer software
Program,or suite of programs,
executed by the processor
Frequently relinquishes control and
must depend on the processor to
allow it to regain control
Kernel (Nucleus):
Contains the most grequently
used functions in OS.
Evolution of Operating
Systems
A major OS will evolve over time
for a number of reasons:
hardware upgrades
new types of hardware
new services
Fixes
Evolution of
Operating Systems
Stages include:
Time
Sharing
Multiprogra Systems
mmed
Batch
Simple Systems
Batch
Systems
Serial
Processi
ng
Serial Processing
Earliest
Problems:
Computers:
Scheduling:
No operating system most installations used a
programmers hardcopy sign-up sheet to
interacted directly with reserve computer time
the computer hardware time allocations could
run short or long,
Computers ran from a
resulting in wasted
console with display lights,
computer time
toggle switches, some form
of input device, and a printer Setup time
Users have access to the
a considerable amount of
computer in “series” time was spent just on
setting up the program to
run
Simple Batch
Systems
Early computers were very expensive
important to maximize processor utilization
Monitor (1st batch OS)
user no longer has direct access to processor
job is submitted to computer operator who
batches them together and places them on
an input device
program branches back to the monitor when
finished
Monitor Point of
View
Monitor controls the
sequence of events
Resident Monitor is
software always in memory
Monitor reads in job one at
a time and gives control
Job returns control to
monitor
Processor Point of
View
Processor executes instruction from the
memory containing the monitor
Executes the instructions in the user program
until it encounters an ending or error condition
“control is passed to a job” means processor is
fetching and executing instructions in a user
program
“control is returned to the monitor” means that
the processor is fetching and executing
instructions from the monitor program
Job Control Language
(JCL)
pecial type of programming language used to provide instructions to the monitor
what compiler to use
what data to use
Desirable Hardware
Features
Memory protection for monitor
• while the user program is executing, it must not alter the memory area containing the monitor
Timer
• prevents a job from monopolizing the system
Privileged instructions
• can only be executed by the monitor
Interrupts
• gives OS more flexibility in controlling user programs (Early OSs do NOT have)
Modes of Operation
User Mode Kernel Mode
• user program executes in • monitor executes in kernel
user mode mode
• certain areas of memory are • privileged instructions may
protected from user access be executed
• certain instructions may not • protected areas of memory
be executed may be accessed
Simple Batch System
Overhead
Processor time alternates between execution of
user programs and execution of the monitor
Sacrifices:
some main memory is now given over to the
monitor
some processor time is consumed by the
monitor
Despite overhead, the simple batch system
improves utilization of the computer
Multiprogrammed
Batch Systems
Processor is
often idle
even with
automatic
job
sequencing
I/O devices
are slow
compared
to
processor
Uniprogramming
The processor spends a certain
amount of time executing, until it
reaches an I/O instruction; it must
then wait until that I/O instruction
concludes before proceeding
Multiprogramming
There must be enough memory to hold the OS
(resident monitor) and one user program
When one job needs to wait for I/O, the processor can
switch to the other job, which is likely not waiting for
I/O
Multiprogramming
Multiprogramming
also known as multitasking
memory is expanded to hold three, four, or more
programs and switch among all of them
Multiprogramming
Example
Table 2.1 Sample Program Execution Attributes
Effects on Resource
Utilization
Table 2.2 Effects of Multiprogramming on Resource Utilization
Values are average
Time-Sharing
Systems
Can be used to handle multiple interactive
jobs
Processor time is shared among multiple
users
Multiple users simultaneously access the
system through terminals, with the OS
interleaving the execution of each user
program in a short burst or quantum of
computation
Batch
Multiprogramming
vs. Time Sharing
Table 2.3 Batch Multiprogramming versus Time Sharing
Compatible Time-
Sharing Systems
CTSS Time Slicing
System clock generates interrupts
One of the first time-sharing at a rate of approximately one
operating systems every 0.2 seconds
At each interrupt OS regained
Developed at MIT by a group
control and could assign processor
known as Project MAC to another user
Ran on a computer with 32,000 At regular time intervals the
36-bit words of main memory, current user would be preempted
with the resident monitor and another user loaded in
consuming 5000 of that
Old user programs and data were
To simplify both the monitor and written out to disk
memory management a Old user program code and data
program was always loaded to were restored in main memory
start at the location of the when that program was next given
5000th word a turn
Major Achievements
Operating
Systems are among the
Major advances in development
include:
most complex pieces of software ever
• processes
• memory management
developed • information protection and security
• scheduling and resource
management
• system structure
Process
Fundamental to the structure of operating
systems
A process can be defined as:
a program in execution
an instance of a running program
the entity that can be assigned to, and executed
on, a processor
a unit of activity characterized by a single
sequential thread of execution, a current state,
and an associated set of system resources
Errors when
designing
OS
Improper Nondeterminate
synchronization
program operation
ensure a process waiting for
an I/O device receives the program should only
signal depend on input to it,
improper design of the not relying on common
signaling mechanism can
memory areas
result in loss or duplication
Deadlocks
Failed mutual it is possible for two or
exclusion more programs to be
more than one user or hung up waiting for
program attempts to each other
make use of a shared
resource at the same
time
Components of
a Process
A The execution context is
process
contains three essential:
it is the internal data by
components: which the OS is able to
an executable supervise and control the
program process
includes the contents of the
the associated data
various process registers
needed by the includes information such
program (variables, as the priority of the
work space, buffers, process and whether the
etc.) process is waiting for the
the execution completion of a particular
I/O event
context (or “process
Process
Management
The entire state of
the process at any
instant is contained in
its context
New features can be
designed and
incorporated into the
OS by expanding the
context to include any
new information
needed to support the
feature
Memory
Management
TheOS has five principal storage
management responsibilities:
long-
automatic support
protectio term
allocation of
process n and storage
and modular
isolation access
managem program
control (via file
ent ming
system)
Virtual Memory
(VM)
Typically, operating systems meet these
requirements with virtual memory and file
system facilities.
VM is a facility that allows programs to address
memory from a logical point of view, without
regard to the amount of main memory physically
available
Conceived to meet the requirement of having
multiple user jobs reside in main memory
concurrently
Paging
Allows processes to be comprised of a number
of fixed-size blocks, called pages
Program references a word by means of a
virtual address
consists of a page number and an offset within
the page
each page may be located anywhere in main
memory
Provides for a dynamic mapping between the
virtual address used in the program and a real
(or physical) address in main memory
Information
Protection
and Security
The nature of the Main
threat that concerns issue availabilit
an organization will s y
vary greatly
depending on the
circumstances authentici confidentialit
ty y
The problem data
involves controlling integrity
access to computer
systems and the
information stored
in them
Scheduling and
Resource
Management
Keyresponsibility
of an OS is
managing
efficienc fairness
resources y
Resource
allocation policies differential
responsiven
must consider: ess
OS Queues
Short-term queue:
consists of processes that are in main memory and are
ready to run as soon as the processor is made
available.
Short-term scheduler determines which one will use
processor first: round-robin, priority order, etc.
The long-term queue:
is a list of new jobs waiting to use the processor.
OS adds jobs to the system by transferring a process
from the long-term queue to the short-term queue.
I/O queue: Many process may request the use
of the same I/O device. Thus, they are lined up
Different
Architectural
Approaches
Demands on operating systems
require new ways of organizing the
OS
Different approaches and design elements have
been tried:
• microkernel architecture
• multithreading
• symmetric multiprocessing
• distributed operating systems
• object-oriented design
Microkernel
Architecture
Assignsonly a few essential functions to
the kernel:
interprocess
address basic
communicatio
spaces scheduling
n (IPC)
The approach:
is well suited
simplifies
provides to a
implementatio
flexibility distributed
n
environment
Multithreading
Technique in which a process, executing an
application, is divided into threads that can run
concurrently
Thread
• dispatchable unit of work
• includes a processor context and its own data area to enable
subroutine branching
• executes sequentially and is interruptible
Process
• a collection of one or more threads and associated system
resources
• programmer has greater control over the modularity of the
application and the timing of application related events
Symmetric
Multiprocessing
(SMP)
Term that refers to a computer hardware
architecture and also to the OS behavior that
exploits that architecture
Several processes can run in parallel
Multiple processors are transparent to the user
these processors share same main memory and
I/O facilities
all processors can perform same functions
The OS takes care of scheduling of threads or
processes on individual processors and of
synchronization among processors
SMP Advantages
more than one process can be
Performan
running simultaneously, each
ce
on a different processor
failure of a single processor
Availability
does not halt the system
performance of a system
Increment
can be enhanced by adding
al Growth
an additional processor
vendors can offer a range of
products based on the number
Scaling
of processors configured in the
system
OS Design
Distributed Object-Oriented
Operating System Design
Provides the illusion of
Used for adding modular
a single main memory extensions to a small
space kernel
single secondary memory Enables programmers to
space
customize an operating
unified access facilities system without disrupting
State of the art for distributed
system integrity
operating systems lags that of
uniprocessor and SMP
Eases the development of
operating systems distributed tools and full-
blown distributed operating
systems
Fault Tolerance
Refers to the ability of a system or component to
continue normal operation despite the presence of
hardware or software faults
Typically involves some degree of redundancy
Intended to increase the reliability of a system
typically comes with a cost in financial terms or
performance
The extent adoption of fault tolerance measures
must be determined by how critical the resource is
Fundamental
Concepts
The basic measures are:
Reliability
R(t)
defined as the probability of its correct operation
up to time t given that the system was operating
correctly at time t=o
Mean time to repair (MTTR)
is the average time it takes to repair or replace a
faulty element
Availability
defined as the fraction of time the system is
available to service users’ requests
Fault Categories
Permanent Spatial (physical) redundancy
A fault that, after it
occurs, is always involves the use of multiple components that either perform
the same function simultaneously or are configured so that
present one component is available as a backup in case of the failure
the fault persists until of another component
the faulty component
is replaced or repaired Temporal redundancy
Temporary involves repeating a function or operation when an error is
detected
A fault that is not effective with temporary faults but not useful for permanent
present all the time for faults
all operating
conditions Information redundancy
can be classified as
Transient – a fault provides fault tolerance by replicating or coding data in such
that occurs only a way that bit errors can be both detected and corrected
once
Intermittent – a
Operating System
Mechanisms
A number of techniques can be incorporated
into OS software to support fault tolerance:
process isolation
Concurrency (Chapter 5 and 6)
virtual machines (Chapter 14)
checkpoints and rollbacks
Like system restore in Win X!
Virtual Machine
Approach
Allows one or more cores to be
dedicated to a particular process and
then leave the processor alone to devote
its efforts to that process
MulticoreOS could then act as a
hypervisor that makes a high-level
decision to allocate cores to applications
but does little in the way of resource
allocation beyond that
Client/Server Model
Windows OS services, Advantages:
environmental it simplifies the Executive
subsystems, and it improves reliability
applications are all it provides a uniform
structured using the means for applications to
client/server model communicate with
services via RPCs without
Common in distributed restricting flexibility
systems, but can be it provides a suitable
used internal to a base for distributed
single system computing
Processes
communicate via RPC
Threads and SMP
Two important characteristics of Windows are its
support for threads and for symmetric
multiprocessing
OS routines can(SMP)
run on any available processor, and different
routines can execute simultaneously on different processors
Windows supports the use of multiple threads of execution
within a single process. Multiple threads within the same
process may execute on different processors simultaneously
server processes may use multiple threads to process requests
from more than one client simultaneously
Windows provides mechanisms for sharing data and resources
between processes and flexible interprocess communication
capabilities
Traditional UNIX
Systems
Were developed at Bell Labs and became operational on a PDP-7 in 1970
Incorporated many ideas from Multics
PDP-11 was a milestone because it first showed that UNIX would be an OS for
all computers
Next milestone was rewriting UNIX in the programming language C
demonstrated the advantages of using a high-level language for system
code
Was described in a technical journal for the first time in 1974
First widely available version outside Bell Labs was Version 6 in 1976
Version 7, released in 1978 is the ancestor of most modern UNIX systems
Most important of the non-AT&T systems was UNIX BSD (Berkeley Software
Distribution)
Modern UNIX
Systems
System V Release 4 (SVR4)
Solaris
BSD
Linux
Solaris 10
Sun’s SVR4-based UNIX release
Provides all of the features of SVR4 plus a
number of more advanced features such
as:
afully preemptable, multithreaded
kernel
full support for SMP
an object-oriented interface to file
systems
Most widely used and most successful
commercial UNIX implementation
LINUX Overview
Started out as a UNIX variant for the IBM PC
Linus Torvalds, a Finnish student of computer science, wrote the
initial version
Linux was first posted on the Internet in 1991
Today it is a full-featured UNIX system that runs on several
platforms
Is free and the source code is available
Key to success has been the availability of free software packages
Highly modular and easily configured
Android Operating
System
A Linux-based system Most recent version is
originally designed for Android 6.0.1
touchscreen mobile devices "Marshmallow" (Dec. 9,
such as smartphones and 2015)
tablet computers
The Open Handset Alliance
The most popular mobile OS (OHA) was responsible for
Development was done by the Android OS releases as
Android Inc., which was an open platform
bought by Google in 2005
The open-source nature of
1st commercial version Android has been the key
(Android 1.0) was released in to its success
2008
Every Android application
runs in its own process with
its own instance of the
Dalvik virtual machine
Android (DVM)
DVM executes files in the
Runtime Dalvik Executable (.dex)
format
Component includes a set
of core libraries that
provides most of the
functionality available in
the core libraries of the
Java programming
language
To execute an operation the
DVM calls on the
corresponding C/C++
library using the Java
Native Interface (JNI)
Summary
Fault tolerance
Operating system
Fundamental concepts
objectives and functions
Faults
User/computer interface
OS mechanisms
Resource manager
OS design considerations for
Evolution of operating
multiprocessor and multicore
systems
Microsoft Windows overview
Serial processing
Simple/multiprogrammed/
Traditional Unix systems
History/description
time-sharing batch
Modern Unix systems
systems
Linux
Major achievements
Android
Developments leading to
modern operating systems