0% found this document useful (0 votes)
16 views47 pages

CSC 553 Operating Systems

An operating system (OS) is a program that manages application execution and serves as an interface between applications and hardware, focusing on convenience, efficiency, and evolution. It provides essential services such as program development, execution, and resource management while evolving through hardware upgrades and new services. Key concepts include process management, memory management, and the transition from simple batch systems to multiprogramming and time-sharing systems to enhance resource utilization.

Uploaded by

pubg0950pubg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views47 pages

CSC 553 Operating Systems

An operating system (OS) is a program that manages application execution and serves as an interface between applications and hardware, focusing on convenience, efficiency, and evolution. It provides essential services such as program development, execution, and resource management while evolving through hardware upgrades and new services. Key concepts include process management, memory management, and the transition from simple batch systems to multiprogramming and time-sharing systems to enhance resource utilization.

Uploaded by

pubg0950pubg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

CSC 553 Operating Systems

Lecture 2- Operating System


Overview

What is an Operating System?


• A program that controls the execution of
application programs
• An interface between applications and
hardware
• Main objectives of an OS:
– Convenience
– Efficiency
– Ability to evolve
Hardware and Software Structure
for a Computer
Application programs
Application
programming interface
Application Libraries/utilities Software
binary interface
Operating system
Instruction Set
Architecture
Execution hardware

Memory
System interconnect
translation Hardware
(bus)

I/O devices
Main
and
memory
networking

Figure 2.1 Computer Hardware and Software Structure

Operating System Services


• Program development
• Program execution
• Access I/O devices
• Controlled access to files
• System access
• Error detection and response
• Accounting
Key Interfaces
• Instruction set architecture (ISA)
• Application binary interface (ABI)
• Application programming interface (API)

The Operating System as


Resource Manager
• The OS is responsible for controlling the
use of a computer’s resources, such as:
– I/O
– Main and secondary memory
– Processor execution time
Operating System
as Resource Manager
• Functions in 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

Operating System as Resource


Manager
Computer System
I/O Devices
Memory
Operating I/O Controller Printers,
System keyboards,
Software digital camera,
I/O Controller etc.

Programs
and Data

I/O Controller

Processor Processor

Storage
OS
Programs

Data

Figure 2.2 The Operating System as Resource Manager


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

Time
Sharing
Multiprogrammed Systems
Batch Systems
Simple Batch
Systems
Serial
Processing
Serial Processing – Earliest
Computers
• No operating system
– Programmers interacted directly with the
computer hardware
• Computers ran from a console with display
lights, toggle switches, some form of input
device, and a printer
• Users have access to the computer in
“series”

Serial Processing - Problems


• Scheduling:
– Most installations used a hardcopy sign-up
sheet to reserve computer time
• Time allocations could run short or long, resulting in
wasted computer time

• Setup time
– A considerable amount of time was spent on
setting up the program to run
Simple Batch Systems
• Early computers were very expensive
– Important to maximize processor utilization
• Monitor
– 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 Interrupt
Processing

sequence of events Device


Drivers
Monitor
Job
• Resident Monitor is Sequencing
Control Language
software always in Boundary
Interpreter

memory
• Monitor reads in job User
Program
Area
and gives control
• Job returns control to
monitor Figure 2.3 Memory Layout for a Resident 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)


Special type of programming
language used to provide
instructions to the monitor

What compiler to use

What data to use


Desirable Hardware Features
Memory protection

• 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

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

I/O devices
are slow
compared to
processor

Even with
automatic
job
sequencing

Processor is often
idle
System Utilization
Read one record from file 15 µs
Execute 100 instructions 1 µs
Write one record to file 15 µs
TOTAL 31 µs

1
Percent CPU Utilization = = 0.032 = 3.2%
31

Figure 2.4 System Utilization Example

Uniprogramming

Program A Run Wait Run Wait

Time
(a) 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
Program A Run Wait Run Wait

Program B Wait Run Wait Run Wait

Run Run Run Run


Combined Wait Wait
A B A B
Time
(b) Multiprogramming with two programs

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
Program A Run Wait Run Wait

Program B Wait Run Wait Run Wait

Program C Wait Run Wait Run Wait

Run Run Run Run Run Run


Combined Wait Wait
A B C A B C
Time
(c) Multiprogramming with three programs
Also known as multitasking
Memory is expanded to hold three, four, or more
programs and switch among all of them
Multiprogramming Example
JOB1 JOB2 JOB3
Type of job Heavy compute Heavy I/O Heavy I/O
Duration 5 min 15 min 10 min
Memory required 50 M 100 M 75 M
Need disk? No No Yes
Need terminal? No Yes No
Need printer? No No Yes

Effects of Multiprogramming on
Resource Utilization
Uniprogramming Multiprogramming
Processor use 20% 40%
Memory use 33% 67%
Disk use 33% 67%
Printer use 33% 67%
Elapsed time 30 min 15 min
Throughput 6 jobs/hr 12 jobs/hr
Mean response time 18 min 10 min
Utilization Histograms for
Uniprogramming and Multiprogramming
100% 100%

CPU CPU
0% 0%
100% 100%

Memory Memory
0% 0%
100% 100%

Disk Disk
0% 0%
100% 100%

Terminal Terminal
0% 0%
100% 100%

Printer Printer
0% 0%

Job History Job History JOB1


JOB1 JOB2 JOB3
JOB2
0 5 10 15 20 25 30
minutes JOB3

time 0 5 10 15
minutes
time
(a) Uniprogramming (b) Multiprogramming

Figure 2.6 Utilization Histograms

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 Timesharing

Batch Multiprogramming Time Sharing


Principal objective Maximize processor use Minimize response time
Source of directives to Job control language Commands entered at the
operating system commands provided with the terminal
job

Compatible Time-Sharing System (CTSS)

• One of the first time-sharing operating


systems
– Developed at MIT by a group known as Project
MAC
– The system was first developed for the IBM
709 in 1961
– Ran on a computer with 32,000 36-bit words of
main memory, with the resident monitor
consuming 5000 of that
Compatible Time-Sharing System
(CTSS)
• CTSS utilized a technique known as time
slicing
– System clock generated interrupts at a rate of
approximately one every 0.2 seconds
– At each clock interrupt the OS regained control
and could assign the processor to another user
– Thus, at regular time intervals the current user
would be pre-empted and another user loaded in

Compatible Time-Sharing System


(CTSS)
• CTSS utilized a technique known as time
slicing
– To preserve the old user program status for later
resumption, the old user programs and data were
written out to disk before the new user programs
and data were read in
– Old user program code and data were restored in
main memory when that program was next given
a turn
0 0 0
Monitor Monitor Monitor
5000 5000 5000
JOB 3
10000
JOB 1
JOB 2
(JOB 2)
20000

Free 25000 25000


Free Free
32000 32000 32000
(a) (b) (c)

0 0 0
Monitor Monitor Monitor
5000 5000 5000
JOB 4
JOB 1
15000 JOB 2
(JOB 1)
20000 20000
(JOB 2) (JOB 2)
25000 25000 25000
Free Free Free
32000 32000 32000
(d) (e) (f)

Figure 2.7 CTSS Operation

Major Achievements
• Operating Systems are among the most
complex pieces of software ever developed
• Major advances in development include:
– Processes
– Memory management
– 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

Causes of Errors

• Improper synchronization
– It is often the case that a routine must be
suspended awaiting an event elsewhere in the
system
– Improper design of the signaling mechanism
can result in loss or duplication
Causes of Errors

• Failed mutual exclusion


– More than one user or program attempts to
make use of a shared resource at the same time
– There must be some sort of mutual exclusion
mechanism that permits only one routine at a
time to perform an update against the file

Causes of Errors

• Nondeterminate program operation


– When programs share memory, and their
execution is interleaved by the processor, they
may interfere with each other by overwriting
common memory areas in unpredictable ways
– The order in which programs are scheduled
may affect the outcome of any particular
program
Causes of Errors

• Deadlocks
– It is possible for two or more
programs to be hung up waiting for
each other

Components of a Process

• A process contains three components:


– An executable program
– The associated data needed by the program
(variables, work space, buffers, etc.)
– The execution context (or “process state”) of
the program
Components of a Process

• The execution context is essential:


– It is the internal data by which the OS is able to
supervise and control the process
– Includes the contents of the various process
registers
– Includes information such as the priority of the
process and whether the process is waiting for
the completion of a particular I/O event

Process Main
Memory
Processor
Registers
Process index i

Management i
PC

Process Base b
list Limit h

• The entire state of the


j

Other
registers
process at any instant is
Context
contained in its context Process Data

• New features can be


A
Program
(code)

designed and incorporated


b
into the OS by expanding Process
Context

h Data
the context to include any B
Program
(code)
new information needed to
support the feature
Figure 2.8 Typical Process Implementation
Memory Management
• The OS has five principal storage
management responsibilities:

Automatic Support of
Process Protection and Long-term
allocation and modular
isolation access control storage
management programming

Virtual Memory

• 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, consisting of a page number and an offset
within the page
• Each page of a process may be located anywhere
in main memory
• The paging system provides for a dynamic
mapping between the virtual address used in the
program and a real address (or physical address)
in main memory

A.1
A.0 A.2
0 0
A.5
1 1
2 2
B.0 B.1 B.2 B.3
3 3
4 4
5 5
6 6
A.7
7 User
A.9
8 program
B
9
A.8
10

User
program
A
B.5 B.6

Main Memory Disk


Main memory consists of a Secondary memory (disk) can
number of fixed-length frames, hold many fixed-length pages. A
each equal to the size of a page. user program consists of some
For a program to execute, some number of pages. Pages for all
or all of its pages must be in programs plus the operating system
main memory. are on disk, as are files.

Figure 2.9 Virtual Memory Concepts


Real
Memory Address
Processor Management
Virtual Unit
Address Main
Memory

Disk
Address

Secondary
Memory

Figure 2.10 Virtual Memory Addressing

Information Protection and Security

• The nature of the


threat that concerns Main
an organization will issues Availability
vary greatly
depending on the
circumstances
Confidentiality
• The problem Authenticity

involves controlling
access to computer Data integrity
systems and the
information stored in
them
Scheduling and Resource Management

• Key responsibility
of an OS is
managing Efficiency
Fairness

resources
• Resource
allocation policies Differential
responsiveness
must consider:

Operating System
Service Call Service
from Process Call
Handler (code)

Long- Short- I/O


Interrupt
Term Term Queues
from Process Interrupt
Queue Queue
Interrupt Handler (code)
from I/O
Short-Term
Scheduler
(code)

Pass Control
to Process

Figure 2.11 Key Elements of an Operating System for Multiprogramming


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
• Assigns only a few essential functions to the
kernel:
Address Interprocess
Basic
space communication
scheduling
management (IPC)

• The approach:

Well suited to a
Simplifies Provides
distributed
implementation flexibility
environment
Multithreading
• Technique in
which a
Thread Process
process,
A collection of one or
executing an Dispatchable unit of
work
more threads and
associated system
resources
application,
is divided Includes a processor
By breaking a single
application into
context and its own
into threads data area for a stack
multiple threads, a
programmer has
greater control over
that can run the modularity of the
application and the
timing of application-
concurrently Executes sequentially related events
and is interruptible

Symmetric Multiprocessing (SMP)


• Term that refers to a computer hardware
architecture and also to the OS behavior that
exploits that architecture
• The OS of an SMP schedules processes or
threads across all of the processors
• The OS must provide tools and functions to
exploit the parallelism in an SMP system
Symmetric Multiprocessing (SMP)
• Multithreading and SMP are often discussed
together, but the two are independent
facilities
• An attractive feature of an SMP is that the
existence of multiple processors is
transparent to the user

SMP Advantages

More than one process can be running


Performance simultaneously, each on a different
processor

Failure of a single process does not


Availability halt the system

Incremental Performance of a system can be


enhanced by adding an additional
Growth processor

Vendors can offer a range of products


Scaling based on the number of processors
configured in the system
Time

Process 1

Process 2

Process 3

(a) Interleaving (multiprogramming, one processor)

Process 1

Process 2

Process 3

(b) Interleaving and overlapping (multiprocessing; two processors)

Blocked Running

Figure 2.12 Multiprogramming and Multiprocessing

OS Design

• Distributed Operating System


– Provides the illusion of a single main memory
space and a single secondary memory space
plus other unified access facilities, such as a
distributed file system
– State of the art for distributed operating systems
lags that of uniprocessor and SMP operating
systems
OS Design

• Object-Oriented Design
– Lends discipline to the process of adding
modular extensions to a small kernel
– Enables programmers to customize an
operating system without disrupting system
integrity
– Also eases the development of 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=0

Fundamental Concepts
• The basic measures are:
– Mean time to failure (MTTF)
• Mean time to repair (MTTR) is the
average time it takes to repair or
replace a faulty element
Fundamental Concepts
• The basic measures are:
– Availability
• Defined as the fraction of time the
system is available to service users’
requests
Availability Classes
Class Availability Annual Downtime
Continuous 1.0 0
Fault Tolerant 0.99999 5 minutes
Fault Resilient 0.9999 53 minutes
High Availability 0.999 8.3 hours
Normal Availability 0.99 - 0.995 44-87 hours

Faults
• Are defined by the IEEE Standards
Dictionary as an erroneous hardware or
software state resulting from:
– Component failure
– Operator error
– Physical interference from the environment
– Design error
– Program error
– Data structure error
Faults
• The standard also states that a fault
manifests itself as:
– A defect in a hardware device or component
– An incorrect step, process, or data definition in
a computer program

Fault Categories

• Permanent
– A fault that, after it occurs, is always
present
– The fault persists until the faulty
component is replaced or repaired
Fault Categories

• Temporary
– A fault that is not present all the time for all
operating conditions
– Can be classified as
• Transient – a fault that occurs only once
• Intermittent – a fault that occurs at multiple,
unpredictable times

Methods of Redundancy

Spatial (physical) Temporal Information


redundancy redundancy redundancy

Involves the use of Involves repeating a


multiple components function or operation
when an error is Provides fault
that either perform
detected tolerance by
the same function
replicating or coding
simultaneously or are
data in such a way
configured so that
that bit errors can be
one component is Is effective with both detected and
available as a backup temporary faults but corrected
in case of the failure not useful for
of another component permanent faults
Operating System Mechanisms

• A number of techniques can be incorporated


into OS software to support fault tolerance:
– Process isolation
– Concurrency controls
– Virtual machines
– Checkpoints and rollbacks

Symmetric Multiprocessor OS
Considerations
• A multiprocessor OS must provide all the
functionality of a multiprogramming system plus
additional features to accommodate multiple
processors
• Key design issues:
– Simultaneous concurrent processes or threads
– Scheduling
– Synchronization
– Memory Management
– Reliability and Fault Tolerance
Symmetric Multiprocessor OS
Considerations
• Simultaneous concurrent processes or
threads:
– Kernel routines need to be reentrant to allow
several processors to execute the same kernel
code simultaneously

Symmetric Multiprocessor OS
Considerations
• Scheduling:
– Any processor may perform scheduling, which
complicates the task of enforcing a scheduling
policy
Symmetric Multiprocessor OS
Considerations
• Synchronization:
– With multiple active processes having potential
access to shared address spaces or shared I/O
resources, care must be taken to provide
effective synchronization

Symmetric Multiprocessor OS
Considerations
• Memory management:
– The reuse of physical pages is the biggest
problem of concern
Symmetric Multiprocessor OS
Considerations
• Reliability and Fault Tolerance:
– The OS should provide graceful degradation in
the face of processor failure

Multicore OS Considerations
• The design challenge
for a many-core
multicore system is to
efficiently harness the Hardware parallelism within each
core processor, known as
multicore processing instruction level parallelism
power and intelligently
manage the substantial Potential for multiprogramming
and multithreaded execution
on-chip resources within each processor
efficiently
Potential for a single application
• Potential for to execute in concurrent
processes or threads across
parallelism exists at multiple cores
three levels:
Grand Central Dispatch (GCD)
• Is a multicore support capability
– Once a developer has identified something that
can be split off into a separate task, GCD makes
it as easy and noninvasive as possible to
actually do so
• In essence, GCD is a thread pool
mechanism, in which the OS maps tasks
onto threads representing an available
degree of concurrency

Grand Central Dispatch (GCD)

• Provides the extension to programming


languages to allow anonymous functions,
called blocks, as a way of specifying tasks
• Makes it easy to break off the entire unit of
work while maintaining the existing order
and dependencies between subtasks
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
• Multicore OS 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

Traditional UNIX Systems


• Developed at Bell Labs and became
operational on a PDP-7 in 1970
• The first notable milestone was porting the
UNIX system from the PDP-7 to the PDP-
11
– First showed that UNIX would be an OS for all
computers
Traditional UNIX Systems
• 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

Traditional UNIX Systems


• 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), running first on PDP and then
on VAX computers
User Programs

Trap
Libraries
User Level

System Call Interface

Inter-process
communication
File Subsystem
Process
Control Scheduler
Subsystem
Memory
Buffer Cache
management

character block
Device Drivers Kernel Level

Hardware Control

Hardware Level

Figure 2.15 Traditional UNIX Kernel

Modern UNIX Kernel coff


a.out elf

exec
switch
NFS
file mappings
FFS
virtual
device memory vnode/vfs
mappings framework interface
s5fs

anonymous RFS
mappings

Common
Facilities

disk driver time-sharing


block processes
device scheduler
switch framework

tape driver system


processes
STREAMS

network tty
driver driver
System V Release 4 (SVR4)

• Developed jointly by AT&T and Sun


Microsystems
• Combines features from SVR3, 4.3BSD,
Microsoft Xenix System V, and SunOS
System V Release 4 (SVR4)

• New features in the release include:


– Real-time processing support
– Process scheduling classes
– Dynamically allocated data structures
– Virtual memory management
– Virtual file system
– Preemptive kernel

BSD
• Berkeley Software Distribution
• 4.xBSD is widely used in academic
installations and has served as the basis of a
number of commercial UNIX products
• 4.4BSD was the final version of BSD to be
released by Berkeley
BSD
• There are several widely used, open-source
versions of BSD:
– FreeBSD
• Popular for Internet-based servers and
firewalls
• Used in a number of embedded
systems

BSD
• There are several widely used, open-source
versions of BSD:
– NetBSD
• Available for many platforms
• Often used in embedded systems
– OpenBSD
• An open-source OS that places special
emphasis on security
Solaris 11
• Oracle’s SVR4-based UNIX release
• Provides all of the features of SVR4 plus a
number of more advanced features such as:
– A fully preemptable, multithreaded kernel
– Full support for SMP
– An object-oriented interface to file systems

You might also like