You are on page 1of 79

Operating Systems

Introduction
Muhammad Najmul Islam Farooqui
Assistant Professor, CED

Week 1

23-Jan-14

Introduction

Operating System Concepts,


Structure, System Calls
Modern Operating Systems

Week 2

30-Jan-14

Processes

Process Concept, Process Control Block, Process


Scheduling
Operations on Processes, Cooperating Processes,
Inter process Communication

Week 3

06-Feb-14

Threads and Multithreading

Thread concepts, difference between process and


threads, Multithreading, thread application
User Level threads, Kernel Level threads, pros and
cons of both types
POSIX and SOLARIS threads

Week 4

13-Feb-14

CPU Scheduling

Basic Concepts, Scheduling Criteria, Scheduling


Algorithms
FCFS, Round Robin, SJF and Priority based
CPU Scheduling in Linux

Week 5

20-Feb-14

Memory Management

Multiprogramming and multitasking issues


Single user and and multi user memory management
OS memory protection

Week 6

27-Feb-14

Virtual Memory

Paging, Segmentation
Page placement and page replacement Algorithms
Page tables

Week 7

05-Mar-14

Concurrency and Process


Synchronization

Concurrent processes, principle of synchronization,


Critical Section Problem, Synchronization Hardware

Week 9

26-Apr-14

Mutual Exclusion and Semaphores

Mutual exclusion its requirements and


implementation
Introduction to Semaphores, HW implementation of
semaphores
Classical problems of synchronization

Week 10

02-Apr-14

Deadlock and starvation

Deadlock and its principles, types of resources


Condition for deadlocks
Resource-Allocation Graph, Wait-for-graph

Week 11

09-Apr-14

Deadlock Handling Techniques

Deadlock prevention, Deadlock Avoidance


Bankers algorithm, safe and unsafe states
Deadlock detection and recovery

Week 12

16-Apr-14

Disk Management

Week 13

23-Apr-14

File concepts and File systems

Disk scheduling algorithms, FIFO, SSTF, C-SCAN,


LOOK, C-LOOK
File Access Methods, Sequential, direct, indexed,
indexed sequential,
File system structure and implementation
File Allocation Methods

Week 14

30-Apr-14

I/O Management and Device Drivers

Types of IO devices, Sequential and Block devices


Device Drivers

Week 15

7-May-14

Advanced Operating Systems

Distributed, Multiprocessor and Real-time


Operating System
Issues in advanced operating Systems

Week 16

14-May-14

Review of post-mid-term Topics


Final Quiz, Paper Pattern Discussion

Reading Resources
Text Book
Reference Books

Specific to the course


General to the topic

Internet Sources

Text Book

Operating System Concepts, 8th Ed


By Abraham Silberschatz, Peter B. Galvin and
Greg Gagne John Wiley & Sons. Inc

Reference Books

Specific to the Course

Operating System, Concepts, Internals, 6th Ed


by William Stallings

Linux Kernel Internals

Computer System Architecture

Operating System
Interface between users and
the machine
Manages hardware and
software resources of the
system
Provides environment in
which other applications can
run

What is an Operating
System?
An OS is a program that acts an
intermediary between the user of a
computer and computer hardware.
Major cost of general purpose computing is
software.

OS simplifies and manages the complexity of


running application programs efficiently.

Principles of Operating Systems Lecture 1

Initial OS interfaces

Modern OS Interfaces

People who changed the way we use


Computers

Ken Thompson Dennis Ritchie Steve Jobs

Bill Gates

Linus Torvalds

Steve Vozniak

Andy Rubin

Operating System

Operating system runs on number of


machines

Computers
Mobile Phones
Tablets
Router/ Switches/ Wireless Access Points
Gaming Consoles
Microwave Oven

Operating Systems
Timeline
Operating System Year
Author/ Company
LEO I

1951

Lyon Electronic Office

OS/360

1964

IBM

MULTICS

1965

MIT/ Bell Labs

Unix

1969

Ken Thompson, Dennis Ritchie

Cray

1976

Cray Research

BSD

1977

Berkley University

86-DOS

1980

Tim Paterson/ Seattle Computer


Products

PC-DOS

1981

IBM

MS-DOS

1982

Microsoft

Novell NetWare

1983

Novell Inc.

Mac OS

1984

Apple

Windows 1.0

1985

Microsoft

MINIX

1987

Andrew S. Tanenbaum

Operating
System

Year

Writer/ Company

OS/2

1987

IBM/ Microsoft

SCO UNIX

1989

Santa Cruz Operation

BeOS

1990

Be Inc.

Linux

1991

Linus Torvalds

Solaris

1992

SUN Microsystems

FreeBSD

1993

The FreeBSD project

Windows95

1995

Microsoft

Windows NT 4.0

1996

Microsoft

Windows XP

2001

Microsoft

Red Hat Enterprise

2000

Red Hat

Fedora Core 1

2003

Fedora Project / Red Hat

Ubuntu

2004

Canonical Ltd.

Windows Vista

2006

Microsoft

Windows 7

2009

Microsoft

Windows 8*

Oct 26,

Microsoft

Goals of an Operating
System
Simplify the execution of user programs and
make solving user problems easier.
Use computer hardware efficiently.

Allow sharing of hardware and software resources.

Make application software portable and


versatile.
Provide isolation, security and protection
among user programs.
Improve overall system reliability

error confinement, fault tolerance, reconfiguration.


Principles of Operating Systems Lecture 1

17

Why should I study Operating


Systems?
Need to understand interaction between the
hardware and applications
New applications, new hardware..
Inherent aspect of society today

Need to understand basic principles in the design


of computer systems
efficient resource management, security, flexibility

Increasing need for specialized operating systems


e.g. embedded operating systems for devices - cell
phones, sensors and controllers
real-time operating systems - aircraft control,
multimedia services
Principles of Operating Systems Lecture 1

18

Computer System
Components

Hardware
Provides basic computing resources (CPU, memory, I/O devices).

Operating System
Controls and coordinates the use of hardware among application
programs.

Application Programs
Solve computing problems of users (compilers, database systems, video
games, business programs such as banking software).

Users
People, machines, other computers

Principles of Operating Systems Lecture 1

19

Operating System Spectrum

Monitors and Small Kernels


special purpose and embedded systems, real-time
systems

Batch and multiprogramming


Timesharing

workstations, servers, minicomputers, timeframes

Transaction systems
Personal Computing Systems
Mobile Platforms, devices (of all sizes)

20

Hardware Complexity
Increases
Moores Law: 2X
transistors/Chip Every 1.5 years

From Berkeley OS course

IntelMulticoreChipsets

Moores Law

FromHennessyandPatterson,ComputerArchitecture:AQuantitative
Principles of Operating Systems Approach,4thedition,Sept.15,2006
Lecture 1

21

Software Complexity Increases

From MITs 6.033 course

22

Abstract View of System


User
User
11

compiler

User
User
22

User
User
33

assembler

...

Text editor

User
User
nn

Database
system

System
Systemand
andApplication
ApplicationPrograms
Programs
Operating
OperatingSystem
System
Computer
Computer
Hardware
Hardware

Principles of Operating Systems Lecture 1

23

Operating System Views

Resource allocator
to allocate resources (software and hardware) of the
computer system and manage them efficiently.

Control program
Controls execution of user programs and operation of
I/O devices.

Kernel
The program that executes forever (everything else
is an application with respect to the kernel).

Principles of Operating Systems Lecture 1

24

Operating System Spectrum

Monitors and Small Kernels


special purpose and embedded systems, real-time
systems

Batch and multiprogramming


Timesharing

workstations, servers, minicomputers, timeframes

Transaction systems
Personal Computing Systems
Mobile Platforms, devices (of all sizes)

Principles of Operating Systems Lecture 1

25

People-to-Computer Ratio Over Time


From David Culler (Berkeley)

Early Systems - Bare Machine


(1950s)
Hardware expensive ; Human cheap

Structure
Large machines run from console
Single user system
Programmer/User as operator

Paper tape or punched cards

Early software
Assemblers, compilers, linkers, loaders, device
From drivers,
John Ousterhout slides
libraries of common subroutines.

Secure execution
Inefficient use of expensive resources
Low CPU utilization, high setup time.

27

Simple Batch Systems


(1960s)

Reduce setup time by batching jobs with similar


requirements.
Add a card reader, Hire an operator
User is NOT the operator
Automatic job sequencing
Forms a rudimentary OS.

Resident Monitor

From John Ousterhout slides

Holds initial control, control transfers to job and then back to monitor.

Problem
Need to distinguish job from job and data from program.

28

Supervisor/Operator
Control
Secure monitor that controls job processing
Special cards indicate what to do.
User program prevented from performing I/O

Separate user from computer

User submits card deck


cards put on tape
tape processed by operator
output written to tape
tape printed on printer

IBM 7094

Problems
Long turnaround time - up to 2 DAYS!!!
Low CPU utilization
From John Ousterhout slides
I/O and CPU could not overlap; slow mechanical devices.

29

Batch Systems - Issues


Solutions to speed up I/O:
Offline Processing
load jobs into memory from tapes, card reading and line printing are
done offline.

Spooling
Use disk (random access device) as large storage for reading as many
input files as possible and storing output files until output devices are
ready to accept them.
Allows overlap - I/O of one job with computation of another.
Introduces notion of a job pool that allows OS choose next job to run
so as to increase CPU utilization.

30

Speeding up I/O

31

Batch Systems - I/O completion

How do we know that I/O is complete?


Polling:
Device sets a flag when it is busy.
Program tests the flag in a loop waiting for
completion of I/O.

Interrupts:
On completion of I/O, device forces CPU to jump to a
specific instruction address that contains the
interrupt service routine.
After the interrupt has been processed, CPU returns
to code it was executing prior to servicing the
interrupt.

32

Multiprogramming

Use interrupts to run multiple programs


simultaneously
When a program performs I/O, instead of polling,
execute another program till interrupt is received.

Requires secure memory, I/O for each


program.
Requires intervention if program loops
indefinitely.
Requires CPU scheduling to choose the next
job to run.

33

Timesharing
Hardware getting cheaper; Human getting expensive

Programs queued for execution in FIFO


order.
Like multiprogramming, but timer device
interrupts after a quantum (timeslice).

Interrupted program is returned to end of FIFO


Next program is taken from head of FIFO

Control card interpreter replaced by


command language interpreter.

34

Timesharing (cont.)

Interactive (action/response)
when OS finishes execution of one command, it
seeks the next control statement from user.

File systems
online filesystem is required for users to access data
and code.

Virtual memory
Job is swapped in and out of memory to disk.

35

Personal Computing
Systems

Hardware cheap ; Human expensive

Single user systems, portable.


I/O devices - keyboards, mice, display screens,
small printers.
Laptops and palmtops, Smart cards, Wireless
devices.
Single user systems may not need advanced CPU
utilization or protection features.
Advantages:
user convenience, responsiveness, ubiquitous

36

Parallel Systems
Multiprocessor systems with more than one
CPU in close communication.
Improved Throughput, economical,
increased reliability.
Kinds:

Vector and pipelined


Symmetric and asymmetric multiprocessing
Distributed memory vs. shared memory

Programming models:
Tightly coupled vs. loosely coupled ,message-based vs.
shared variable

37

Parallel Computing
Systems
ILLIAC 2
(UIllinois)

Climate
modeling,
earthquake
simulations,
genome
analysis,
protein folding,
nuclear fusion
research, ..

Kcomputer(Japan
)

Tianhe-1(China)

IBM Blue Gene

Connection Machine
(MIT)
38

Distributed Systems
Hardware very cheap ; Human very expensive

Distribute computation among many processors.


Loosely coupled no shared memory, various communication lines

client/server architectures
Advantages:

resource sharing
computation speed-up
reliability
communication - e.g. email

Applications - digital libraries, digital multimedia

39

Distributed Computing
Systems
Globus Grid Computing Toolkit

PlanetLab

Cloud Computing Offerings

Gnutella P2P Network


40

Real-time systems
Correct system function depends on
timeliness
Feedback/control loops
Sensors and actuators
Hard real-time systems

Failure if response time too long.


Secondary storage is limited

Soft real-time systems Less accurate if response time is too long.


Useful in applications such as multimedia, virtual
reality.
41

Key Elements of an
Operating System

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
spaces

interprocess
communicatio
n (IPC)

basic
scheduling

The approach:
simplifies
implementatio
n

provides
flexibility

is well suited
to a
distributed
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 the same functions
The OS takes care of scheduling of threads or processes
on individual processors and of synchronization among
processors

SMP Advantages
Performan
ce

more than one process can be


running simultaneously, each
on a different processor

Availability

failure of a single process


does not halt the system

Increment
al Growth

performance of a system
can be enhanced by adding
an additional processor

Scaling

vendors can offer a range of


products based on the number
of processors configured in the
system

Mul
tipr
ogr
am
min
g

OS Design
Distributed Operating
System

Object-Oriented Design

Provides the illusion of


a single main memory space
single secondary memory
space
unified access facilities

State of the art for


distributed operating
systems lags that of
uniprocessor and SMP
operating systems

Used for adding modular


extensions to a small
kernel
Enables programmers to
customize an operating
system without disrupting
system integrity
Eases the development of
distributed tools and fullblown distributed
operating systems

Virtual Machines and


Virtualization

Virtualization
enables a single PC or server to simultaneously run
multiple operating systems or multiple sessions of a
single OS
a machine can host numerous applications, including
those that run on different operating systems, on a
single platform
host operating system can support a number
of virtual machines (VM)
each has the characteristics of a particular
OS and, in some versions of virtualization,
the characteristics of a particular hardware
platform

Virtual
Memor
y
Concep
t

Virtual Machine
Architecture
Process perspective:
the machine on which it executes consists of the virtual memory
space assigned to the process
the processor registers it may use
the user-level machine instructions it may execute
OS system calls it may invoke for I/O
ABI defines the machine as seen by a process
Application perspective:
machine characteristics are specified by high-level language
capabilities and OS system library calls
API defines the machine for an application
OS perspective:
processes share a file system and other I/O resources
system allocates real memory and I/O resources to the processes
ISA provides the interface between the system and machine

Process and System Virtual


Machines

Process and System Virtual Machines

Symmetric Multiprocessor OS
Considerations
A multiprocessor OS must provide all the
functionality of a multiprogramming
system plus additional features to
Reliabilit
Simultaneo
Memory
with
multiple
Scheduli
Synchroniza
accommodate
multiple
processors
y and
us
manageme
active
ng
tion
fault
any
concurrent
ntreuse
the
processes

toleranc
Key design
issues:having
processor
processes
of

kernel
or threads
routines
need to be
reentrant to
allow
several
processors
to execute
the same
kernel code
simultaneou
sly

may
perform
scheduling,
which
complicate
s the task
of
enforcing a
scheduling
policy

potential
access to
shared
address
spaces or
shared I/O
resources,
care must be
taken to
provide
effective

physical
pages is
the
biggest
problem
of
concern

e
the OS
should
provide
graceful
degradatio
n in the
face of
processor
failure

Multicore OS
Considerations
The design challenge
for a many-core
multicore system is to
efficiently harness the
multicore processing
power and
intelligently manage
the substantial onchip resources
efficiently
Potential for
parallelism exists at
three levels:

hardware parallelism within each


core processor, known as
instruction level parallelism

potential for multiprogramming


and multithreaded execution
within each processor

potential for a single application to


execute in concurrent
processes or threads across
multiple cores

Grand Central Dispatch

Developer must decide what pieces can


or should be executed simultaneously or
in parallel
Grand Central Dispatch (GCD)

implemented in Mac Os X 10.6


helps a developer once something has been identified
that can be split off into a separate task
thread pool mechanism
allows anonymous functions as a way of specifying
tasks

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
Multi-core 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

Microsoft Windows
Overview

MS-DOS 1.0 released in 1981

4000 lines of assembly language


source code

ran in 8 Kbytes of memory

used Intel 8086 microprocessor

Windows 2000
included services and functions
to support distributed processing
Active Directory
plug-and-play and powermanagement facilities

Windows XP released in 2001

Windows 3.0 shipped in 1990

16-bit

GUI interface

implemented as a layer on top of MSDOS

Windows 95

goal was to replace the versions


of Windows based on MS-DOS
with an OS based on NT

32-bit version

Windows Vista shipped in 2007

led to the development of


Windows 98 and Windows Me

Windows Server released in


2008

Windows NT (3.1) released in 1993

32-bit OS with the ability to


support older DOS and Windows
applications as well as provide
OS/2 support

Windows 7 shipped in 2009, as


well as Windows Server 2008
R2

Windows Azure

targets cloud computing

Windows Architecture

Kernel-Mode Components of
Windows

Executive
contains the core OS services

Kernel
controls execution of the processors

Hardware Abstraction Layer (HAL)


maps between generic hardware commands and responses
and those unique to a specific platform

Device Drivers
dynamic libraries that extend the functionality of the
Executive

Windowing and Graphics System


implements the GUI functions

User-Mode Processes

Four basic types are supported by


Windows:

Special System
Processes

Service Processes
Environment
Subsystems
User Applications

user-mode services needed to manage the system

the printer spooler, event logger, and user-mode components that


cooperate with device drivers, and various network services

provide different OS personalities (environments)

executables (EXEs) and DLLs that provide the functionality users


run to make use of the system

Client/Server Model

Windows OS services,
environmental
subsystems, and
applications are all
structured using the
client/server model

Common in distributed
systems, but can be
used internal to a single
system
Processes communicate
via RPC

Advantages:

it simplifies the Executive


it improves reliability
it provides a uniform
means for applications to
communicate with
services via RPCs without
restricting flexibility
it provides a suitable
base for distributed
computing

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

Windows Objects
Windows draws heavily on the concepts
of object-oriented design
Key object-oriented concepts used by
Windows are:

Encapsulati
on

Object
class
and
instance

Inheritance

Polymorphis
m

tc
e
O
b
j lorC
n
o
tn
le
K
re
W
n
d
w
os
i

Windows 7

Changes and improvements:


Engineering improvements
the system is now built in layers which can be separately tested
Performance improvements
amount of memory required has been reduced
Reliability improvements
user-mode heap is more tolerant of memory allocation errors by
C/C++ programmers
Energy efficiency
many improvements have been made
Security
BitLocker is now easier to set up and use
Thread improvements
can support hundreds of CPUs
Dynamic Fair Share Scheduling (DFSS)

Traditional UNIX Systems

Were developed at Bell Labs and became operational on a PDP-7 in 1970


Incorporated many ideas from Multics
PDP-11was 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)

Description
of
UNIX

Traditional
UNIX
Kernel

Modern
UNIX
Kernel

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

Modular
Monolithic Kernel

Includes virtually all of the


OS functionality in one
large block of code that
runs as a single process
with a single address
space

All the functional


components of the kernel
have access to all of its
internal data structures
and routines

Linux is structured as a
collection of modules

Relatively independent
blocks
A module is an object file
whose code can be linked
to and unlinked from the
kernel at runtime
A module is executed in
kernel mode on behalf of
the current process
Have two important
Loadable
Modules
characteristics:

Dynamic linking
Stackable modules

Linux
Kernel
Modul
es

Linux Kernel Components

Linux Signals

Table 2.5 Some Linux Signals

Linux Vserver Virtual Machine


Architecture
Open-source, fast,
lightweight approach to
implementing virtual
machines on a Linux
server
Only a single copy of the
Linux kernel is involved
Supports a number of
separate virtual servers
Each virtual server is
isolated from the others
Involves four elements:

chroot
chroot UNIX
UNIX or
or
Linux
command
Linux command to
to
make
make the
the root
root
directory
directory become
become
something
something other
other
than
than its
its default
default

chcontext
chcontext allocates
allocates
a
a new
new security
security
context
context

chbind
chbind executes
executes a
a
command
command and
and locks
locks
the
the resulting
resulting process
process
and
and its
its children
children into
into
using
using a
a specific
specific IP
IP
address
address

capabilities
capabilities a
a
partitioning
partitioning of
of the
the
privileges
privileges available
available
to
to a
a root
root user
user

Linux Vserver
Architecture

Summary of lecture
What is an operating system?
Early Operating Systems
Simple Batch Systems
Multiprogrammed Batch Systems
Time-sharing Systems
Personal Computer Systems
Parallel and Distributed Systems
Real-time Systems

79

You might also like