Lecture - 1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 44

Operating Systems

Dr. Omer Chughtai


Assistant Professor
Electrical and Computer Engineering
Department

[email protected]
Chapter 1: Introduction

Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne


Chapter 1: Introduction
 What Operating Systems Do
 Computer-System Organization
 Computer-System Architecture
 Operating-System Structure
 Operating-System Operations
 Process Management
 Memory Management
 Storage Management
 Protection and Security
 Kernel Data Structures
 Computing Environments
 Open-Source Operating Systems

Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne
Objectives
 To describe the basic organization of computer systems
 To provide a grand tour of the major components of
operating systems
 To give an overview of the many types of computing
environments
 To explore several open-source operating systems

Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne
What is an Operating System?
 A program that acts as an intermediary between a user of a
computer and the computer hardware
 Operating system goals:
 Execute user programs and make solving user problems
easier
 Make the computer system convenient to use
 Use the computer hardware in an efficient manner
Operating
System
Allocates
Resources

Manages
Disks & Files

Monitors
Activities

Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne
Computer System Structure
 Computer system can be divided into four
components:
 Hardware – provides basic computing
resources
 CPU, memory, I/O devices
 Operating system
 Controls and coordinates use of hardware
among various applications and users
 Application programs – define the ways in
which the system resources are used to solve
the computing problems of the users
 Word processors, compilers, web browsers,
 database systems, video games
 Users
 People, machines, other computers

Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne
Four Components of a Computer System

User User User User


1 2 3 ……… n

Compiler Assembler Text Database


Editor
……… System

System and Application


Programs

Operating
System

Computer
Hardware

Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne
What Operating Systems Do
 Depends on the point of view
 Users want convenience, ease of use and good
performance
 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
 Handheld computers are resource poor, optimized for
usability and battery life
 Some computers have little or no user interface, such
as embedded computers in devices
User and automobiles
Ease of Use

Viewpoint of
Operating System
Resource
System
Utilization
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne
Operating System Definition
 OS is a resource allocator
 Manages all resources
 Decides between conflicting requests for efficient
and fair resource use
 OS is a control program
 Controls execution of programs to prevent errors
and improper use of the computer
 I/O is accessed via Operating Systems

Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne
Operating System Definition (Cont.)
 No universally accepted definition
 “Everything a vendor ships when you order an
operating system” is a good approximation
 But varies wildly
 “The one program running at all times on the
computer” is the kernel.
 Everything else is either
 a system program (ships with the operating
system) , or
 an application program.

Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne
Computer Startup
 bootstrap program is loaded at power-up or reboot
 Typically stored in ROM or EPROM, generally
known as firmware
 Initializes all aspects of system
 Loads operating system kernel and starts
execution

Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne
Computer System Organization
 Computer-system operation
 One or more CPUs, device controllers connect through
common bus providing access to shared memory
 Concurrent execution of CPUs and devices competing
for memory cycles

Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne
Computer-System Operation
 I/O devices and the CPU can execute concurrently
 Each device controller is in charge of a particular device
type
 Each device controller has a local buffer
 CPU moves data from/to main memory to/from local
buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its
operation by causing an interrupt

Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne
Common Functions of Interrupts
 Interrupt transfers control to the interrupt service
routine generally, through the interrupt vector,
which contains the addresses of all the service
routines
 Interrupt architecture must save the address of the
interrupted instruction
 A trap or exception is a software-generated
interrupt caused either by an error or a user request
 An operating system is interrupt driven

Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne
Interrupt- Example
 The program is running, and could be executing any instruction,
which we call instruction M.
 A switch tied to Port H is pushed and activates a Port H interrupt.
 The Port H interrupt vector is located at address $3E4C-$3E4D. The
program finishes the current instruction M and then jumps to the
address of the interrupt vector.
 Now at address $3E4C-$3E4D, the program reads the values $107B
stored there and then jumps to this new address.
 The code beginning at address $107B is the beginning of our
interrupt service routine (ISR). The command "movb #$00, 1100" is
thus executed.
 Program continues to sequentially execute the instructions in the
ISR following the "movb #$00, 1100" command. Program execution
continues in the ISR until the RTI (return from interrupt) instruction
is hit.
 Once we hit the RTI instruction, the program jumps out of the ISR
and back to the regular program. The position in the program will
be the next instruction N that follows instruction M that we were
executing when the interrupt occurred.
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne
Operating-System Operations
 Interrupt driven (hardware and software)
 Hardware interrupt by one of the devices
 Software interrupt (exception or trap):
 Software error (e.g., division by zero)
 Request for operating system service
 Other process problems include infinite
loop, processes modifying each other or the
operating system

Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne
Interrupt Handling
 The operating system preserves the state of the
CPU by storing registers and the program counter
 Determines which type of interrupt has occurred:
 polling
 vectored interrupt system
 Separate segments of code determine what action
should be taken for each type of interrupt

Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne
Interrupt Timeline

Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne
Direct Memory Access Structure
 A mechanism where hardware components move data
between its memory and main memory (RAM) without
the involvement of CPU
 Used for high-speed I/O devices able to transmit
information at close to memory speeds
 Device controller transfers blocks of data from buffer
storage directly to main memory without CPU
intervention
 Only one interrupt is generated per block, rather than the
one interrupt per byte

Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne
Internal DMA reduces the time and reduces the
Registers
efforts of CPU in transferring the data
We want CPU to perform complex tasks
rather than transferring the data from one
end to another.

CPU
Memory

Internal
Buffers USB/Device

IO Interface

DMA is a controller which will do/control


the data transfer

Memory

Internal
Buffers USB/Device
DMA
IO Interface

Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne
Small Controller that allows the transfer
between the device or I/O and the memory

Device
CPU DMAC

ADDR

Memory
COUNT

Control
Signals

I/O or Device
Controller

BUS

Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne
If count = 0 CPU sends signal to device controller
then DMA sends to get the data from the device If Count = 0
interrupt signal
Device then data
to CPU and the CPU DMAC Data transfer is
bus is given

Request for
back to CPU done, if not
then the

Data
same process

send data to memory


DMA sends the RQ to
ADDR repeats

Memory
COUNT
Device CPU is
controller required to
sends the initialize/set
Control FIFO/ data to
the control
Signals BUFFER memory
registers

Sends
ACK to
DMAC I/O or Device
Set the Controller
Registers

BUS

DMAC Check the Byte count, that how


many words/bytes have been transferred
Count register is decremented by 1
Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne
How a Modern Computer Works

A von Neumann architecture

Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne
Storage Definitions and Notation Review
The basic unit of computer storage is the bit. A bit can contain one of two
values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent:
numbers, letters, images, movies, sounds, documents, and programs, to name
a few. A byte is 8 bits, and on most computers it is the smallest convenient
chunk of storage. For example, most computers don’t have an instruction to
move a bit but do have one to move a byte. A less common term is word,
which is a given computer architecture’s native unit of data. A word is made up
of one or more bytes. For example, a computer that has 64-bit registers and
64-bit memory addressing typically has 64-bit (8-byte) words. A computer
executes many operations in its native word size rather than a byte at a time.

Computer storage, along with most computer throughput, is generally measured


and manipulated in bytes and collections of bytes.
A kilobyte, or KB, is 1,024 bytes
a megabyte, or MB, is 1,0242 bytes
a gigabyte, or GB, is 1,0243 bytes
a terabyte, or TB, is 1,0244 bytes
a petabyte, or PB, is 1,0245 bytes

Computer manufacturers often round off these numbers and say that a
megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking
measurements are an exception to this general rule; they are given in bits
(because networks move data a bit at a time).

Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne
Storage Structure
 General purpose computers run their programs from random
access memory called main memory.
 Interaction with main memory is achieved through a series of
load and store instructions to specific memory addresses.
 Load instruction moves a word from main memory to an
internal register of the CPU.
 Store instruction moves content of a register to main
memory.
 The CPU automatically loads instructions from main
memory for execution.
 Instruction execution cycle works as:
 Fetch instruction from memory and stores instruction in
the instruction register.
 Decodes instruction and may cause operands to be
fetched from memory and store in the internal register.
 After instruction on operands executed, result is stored
back in memory.

Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne
Storage Structure
 The memory unit only sees a stream of memory
addresses; it does not know how they are generated.
 We are only interested in sequence of memory addresses
generated by the running program.
 Ideally we want all the programs and data to reside in
the main memory permanently, but it is not possible for
the following two reasons:
 Main memory is too small to store all the programs
and data permanently.
 Main memory is volatile storage device that loses its
contents when power is turned off.

Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne
Storage Structure
• For this reason most computer systems provide
secondary storage as an extension of main memory.
• The main requirement of secondary storage is that it
can hold large quantity of data.
• Most of the secondary storage devices are magnetic
disks which provide storage for both programs and
data.
• There are other types of storage devices as well for
which the speed, cost, size and volatility differ.

Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne
Storage Structure
 Main memory – only large storage media that the CPU can
access directly
 Random access
 Typically volatile
 Secondary storage – extension of main memory that provides
large nonvolatile storage capacity
 Hard disks – rigid metal or glass platters covered with
magnetic recording material
 Disk surface is logically divided into tracks, which are subdivided
into sectors
 The disk controller determines the logical interaction between
the device and the computer
 Solid-state disks – faster than hard disks, nonvolatile
 Various technologies
 Becoming more popular

Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne
Storage Hierarchy
 Storage systems organized in hierarchy
 Speed
 Cost
 Volatility
 Caching – copying information into faster storage
system; main memory can be viewed as a cache for
secondary storage
 Device Driver for each device controller to manage I/O
 Provides uniform interface between controller and
kernel

Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne
Storage-Device Hierarchy

Operating System Concepts – 9th Edition 1.30 Silberschatz, Galvin and Gagne
Caching
 Important principle, performed at many levels in a
computer (in hardware, operating system, software)
 Information in use copied from slower to faster storage
temporarily
 Faster storage (cache) checked first to determine if
information is there
 If it is, information used directly from the cache (fast)
 If not, data copied to cache and used there
 Cache smaller than storage being cached
 Cache management important design problem
 Cache size and replacement policy

Operating System Concepts – 9th Edition 1.31 Silberschatz, Galvin and Gagne
Operating-System Operations
 Dual-mode operation allows OS to protect itself and other
system components
 User mode and kernel mode
 User Mode
 The system is in user mode when the operating system is
running a user application such as handling a text editor. The
transition from user mode to kernel mode occurs when the
application requests the help of operating system or an
interrupt or a system call occurs.
 The mode bit is set to 1 in the user mode. It is changed from
1 to 0 when switching from user mode to kernel mode.
 Kernel Mode
 The system starts in kernel mode when it boots and after the
operating system is loaded, it executes applications in user
mode. There are some privileged instructions that can only
be executed in kernel mode.
 These are interrupt instructions, input output management
etc. If the privileged instructions are executed in user mode,
it is illegal and a trap is generated. Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 1.32
Operating-System Operations (cont.)
• Mode bit provided by hardware to indicate the current mode:
kernel (0) or user (1).
When an interrupt or fault occurs hardware switches to
monitor/kernel mode
 Provides ability to distinguish when system is running user
code or kernel code
 Some instructions designated as privileged, only
executable in kernel mode
 System call changes mode to kernel, return from call resets
it to user

Interrupt/fault

Kernel User
set user mode

Operating System Concepts – 9th Edition 1.33 Silberschatz, Galvin and Gagne
Transition from User to Kernel Mode

Operating System Concepts – 9th Edition 1.34 Silberschatz, Galvin and Gagne
Computer-System Architecture
 Most systems use a single general-purpose processor
 Most systems have special-purpose processors as well
 Multiprocessors systems growing in use and importance
 Also known as parallel systems, tightly-coupled systems
 Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault
tolerance
 Two types:
1. Asymmetric Multiprocessing – each processor is
assigned a specie task.
2. Symmetric Multiprocessing – each processor performs
all tasks

Operating System Concepts – 9th Edition 1.35 Silberschatz, Galvin and Gagne
A Dual-Core Design
 Multi-chip and multicore
 Systems containing all chips
 Chassis containing multiple separate systems

Operating System Concepts – 9th Edition 1.36 Silberschatz, Galvin and Gagne
Types of Multiprocessors
Two types:
1. Asymmetric Multiprocessing – each processor is
assigned a specie task.
2. Symmetric Multiprocessing – each processor
performs all tasks

Operating System Concepts – 9th Edition 1.37 Silberschatz, Galvin and Gagne
Types of Multiprocessors
SYMMETRIC ASYMMETRIC
BASIS FOR COMPARISON
MULTIPROCESSING MULTIPROCESSING
Basic Each processor run the Only Master processor
tasks in Operating run the tasks of
System. Operating System.
Process Processor takes Master processor assign
processes from a processes to the slave
common ready queue, or processors, or they have
there may be a private some predefined
ready queue for each processes.
processor.
Architecture All processor in All processor in
Symmetric Asymmetric
Multiprocessing has the Multiprocessing may
same architecture. have same or different
architecture.
Communication All processors Processors need not
communicate with communicate as they
another processor by a are controlled by the
shared memory. master processor.
Failure If a processor fails, the If a master processor
computing capacity of fails, a slave is turned to
Operating System Concepts – 9th Edition
the system
1.38
reduces. the master processor
Silberschatz, Galvin to
and Gagne
Symmetric Multiprocessing Architecture

Operating System Concepts – 9th Edition 1.39 Silberschatz, Galvin and Gagne
Clustered Systems
 Like multiprocessor systems, but multiple systems
working together
 Usually sharing storage via a storage-area network
(SAN)
 Some clusters are for high-performance computing
(HPC)
• Applications must be written to use parallelization
• Clustered systems are similar to parallel systems as
they both have multiple CPUs.
• However a major difference is that clustered systems
are created by two or more individual computer
systems merged together. Basically, they have
independent computer systems with a common storage
and the systems work together.
• Provides a high-availability service which survives
failures
• Asymmetric clustering has one machine in hot-
standby mode
Symmetric clustering has
• Concepts – 9th Edition
Operating System 1.40 multiple nodes running
Silberschatz, Galvin and Gagne
Clustered Systems

Operating System Concepts – 9th Edition 1.41 Silberschatz, Galvin and Gagne
Asymmetric Clustering
• In this system, one of the nodes in the clustered system is in hot standby
mode and all the others run the required applications.
• The hot standby mode is a failsafe in which a hot standby node is part of
the system . The hot standby node continuously monitors the server and if
it fails, the hot standby node takes its place.

Operating System Concepts – 9th Edition 1.42 Silberschatz, Galvin and Gagne
Asymmetric Clustering
• There is a master node in asymmetric clustering that
directs all the slaves nodes to perform the tasks
required. The requests are delegated by the master node.
• A distributed cache is used in asymmetric clustering to
improve the performance of the system.
• Resources such as memory, peripheral devices etc. are
divided between the nodes of the asymmetric clustering
system at boot time.

Operating System Concepts – 9th Edition 1.43 Silberschatz, Galvin and Gagne
Symmetric Clustering

In symmetric clustering system two or more nodes all run


applications as well as monitor each other. This is more
efficient than asymmetric system as it uses all the hardware
and doesn't keep a node merely as a hot standby

Operating System Concepts – 9th Edition 1.44 Silberschatz, Galvin and Gagne

You might also like