0% found this document useful (0 votes)
106 views73 pages

Os - Lecture - Complete (w1+2)

The document provides an introduction and overview of an operating systems course. It outlines the course contents which include computer and operating system structures, process management, memory management, and more. It describes the course structure as having lectures, labs, assignments, and exams. It also lists recommended textbooks and online resources for the course.

Uploaded by

syed kashif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
106 views73 pages

Os - Lecture - Complete (w1+2)

The document provides an introduction and overview of an operating systems course. It outlines the course contents which include computer and operating system structures, process management, memory management, and more. It describes the course structure as having lectures, labs, assignments, and exams. It also lists recommended textbooks and online resources for the course.

Uploaded by

syed kashif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 73

OPERATING SYSTEMS

Course Introduction, Operating


System Overview
Week#1, CS3104-Operating Systems
Syed Sherjeel Ahmad Gilani, F-2019
Instructor
 Syed Sherjeel Ahmad Gilani
Faculty of Computing,
Riphah International University
sherjeel.gilani@riphah.edu.pk
sherjeelgilani@gmail.com
Room # 213

2
What is an Operating System ?

An operating
OS as a course?
system
To provide an
is a program that
introduction to
acts as an
operating systems;
intermediary
what they do, how
between a user of
they are used, and
a computer and
how they are
the
implemented
computer
hardware.

[Image source: wikipedia]


3
What you will learn?

4
Course Contents
 Computer and operating system structures
 Process and thread management
 Process scheduling
 Resource management
 Process synchronization and communication
 Memory management
 Virtual memory management
 Deadlock management

5
How will this course work?

6
Course Structure
Lectures (Three in a week)–Tuesday & Wednesday
Lab sessions (One in a week) -
Individual and/or group assignments (Plagiarism policy)
Default due date is: before or during the first lecture of the
week
 Quizzes (Announced and Unannounced)
 Midterm (7th or 8th week)
 End term exam
And, off course, 75% attendance is mandatory to sit
in the final exam, as per Riphah policy.

7
Material
 Lecture Notes
 Lab Hand-outs

 Recommended Books
 Operating System Concepts
Essentials, by Abraham Silberschatz,
Peter B. Galvin, & Greg Gagne
(9th Edition)

Modern Operating Systems by


Andrew S. Tanenbaum

8
Online Resources (Course home page)
 http://vle.riphah.edu.pk
 Check at least twice per week!
 Lecture notes, Lab hand-outs, Attendance
etc.

 Note: Please report your attendance and marks if entered


9
incorrectly.
Chapter 1: Introduction
 What is an Operating System?
 What Operating Systems Do?
 Computer System and Operating System
Structure
 Mainframe Systems
 Desktop Systems
 Multiprocessor Systems
 Distributed Systems
 Clustered System
 Real -Time Systems
 Handheld Systems
11
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.

12
What is an Operating System?
 An interface between users and hardware - an
environment "architecture”
 Allows convenient usage; hides the tedious
stuff
 Allows efficient usage; parallel activity, avoids
wasted cycles
 Provides information protection
 Gives each user a slice of the resources
 Acts as a control program.
13
Operating System

14
Computer System Structure
 Computer system can be divided into four
components:
 Hardware – provides basic computing resources
i.e. 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 – i.e. People, machines, etc.
15
OPERATING SYSTEM The Layers Of
OVERVIEW A System

Humans

Program Interface

User Programs

O.S. Interface

O.S.

Hardware Interface/
Privileged Instructions

Disk/Tape/Memory
16
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

17
Operating System Definition (Cont.)
 No universally accepted definition

 “Everything a vendor ships when you order


an operating system”

 “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.

18
What Operating Systems Do?
 Depends on the point of view
 Users want convenience, ease of use
 Don’t care about resource utilization
 Shared computers 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 and
19 automobiles
OPERATING SYSTEM
Components
OVERVIEW
 The CPU is wasted if a job waits for I/O. This leads to:

 Multiprogramming ( dynamic switching ). While one job


waits for a resource, the CPU can find another job to run. It
means that several jobs are ready to run and only need the
CPU in order to continue.
 CPU scheduling is the subject of Chapter 5.
 All of this leads to:
 memory management
 resource scheduling
 deadlock protection

which are the subject of the rest of this course.


20
OPERATING SYSTEM
Characteristics
OVERVIEW
Other Characteristics include:
 Time Sharing - multiprogramming environment that's also interactive.

 Multiprocessing - Tightly coupled systems that communicate via shared


memory. Used for scientific applications. Used for speed improvement by putting
together a number of off-the-shelf processors.

 Distributed Systems - Loosely coupled systems that communicate via message


passing. Advantages include resource sharing, speed up, reliability,
communication.

 Real Time Systems - Rapid response time is main characteristic. Used in


control of applications where rapid response to a stimulus is essential.
21
Computer System and Operating
System Architectures

22
Batch Processing (Mainframe Systems)
• Executing a series of noninteractive jobs all at one time.
• The term originated in the days when users entered
programs on punch cards.
• System operator, feed them into the computer
• The user cannot interact with the job when it is executing
The user must set up the control cards to handle all
possible outcomes
• In a batch system, programs cannot be debugged. A
programmer cannot modify a program as it executes to
study its behavior
• No Interactive Development

23
Mainframes: Batch processing [source IBM]

24 Operating Systems (S-2018)


Mainframes: Batch processing
1. At night, numerous batch jobs running
programs and utilities are processed. These
jobs consolidate the results of the online
transactions that take place during the day.
2. The batch jobs generate reports of business
statistics.
3. Backups of critical files and databases are
made before and after the batch window.
4. Reports with business statistics are sent to a
specific area for analysis the next day.
5. Reports with exceptions are sent to the
branch offices.
25
Mainframes: Batch processing
6. Monthly account balance reports are generated
and sent to all bank customers.
7. Reports with processing summaries are sent to
the partner credit card company.
8. A credit card transaction report is received from
the partner company.
9. In the production control department, the
operations area is monitoring the messages on
the system console and the execution of the
jobs.
10. Jobs and transactions are reading or updating
the database (the same one that is used by
online transactions) and many files are written
26 to tape.
OS Features Needed for Multiprogramming

 I/O routine supplied by the system.


 Memory management – the system

must allocate the memory to several


jobs.
 CPU scheduling – the system must

choose among several jobs ready to


run.
 Allocation of devices.

27
Time-Sharing Systems–Interactive Computing

 The CPU is multiplexed among several


jobs that are kept in memory and on disk
(the CPU is allocated to a job only if the
job is in memory).
 A job swapped in and out of memory to
the disk.
 On-line communication between the user
and the system is provided; when the
operating system finishes the execution of
one command, it seeks the next “control
statement” from the user’s keyboard.
 On-line system must be available for users
to access data and code.
28
Desktop Systems
 Personal computers – computer system
dedicated to a single user.
 I/O devices – keyboards, mice, display
screens, small printers.
 User convenience and responsiveness.
 Can adopt technology developed for larger
operating system’ often individuals have
sole use of computer and do not need
advanced CPU utilization of protection
features.
 May run several different types of
operating systems (Windows, MacOS,
UNIX, Linux)
29
Parallel Systems
 Multiprocessor systems with more than one
CPU in close communication.
 Tightly coupled system – processors share
memory and a clock; communication usually
takes place through the shared memory.
 Advantages of parallel system:
 Increased throughput
 Economical
 Increased reliability

30
Parallel Systems (Cont.)
 Symmetric multiprocessing (SMP)
 Each processor runs an identical copy of the operating
system.
 Many processes can run at once without performance
deterioration.
 Most modern operating systems support SMP

UNIX
SUNOS Version 5 (Solaris2)

 Asymmetric multiprocessing
 Each processor is assigned a specific task; master
processor schedules and allocated work to slave
processors.
 More common in extremely large systems

SUNOS Version 4
31
Symmetric Multiprocessing Architecture

32
A Dual-Core Design

33
Distributed Systems
 Distribute the computation among several
physical processors.
 Loosely coupled system – each processor
has its own local memory; processors
communicate with one another through
various communication lines, such as
high-speed buses or telephone lines.
 Advantages of distributed systems.
 Resources Sharing
 Computation speed up – load sharing
 Reliability
 Communications

34
Distributed Systems (cont)
 Requires networking infrastructure.
 Local area networks (LAN) or Wide area
networks (WAN)
 May be either client-server or peer-to-
peer systems.

35
General Structure of Client-Server

36
Peer-to-Peer Computing
 Another model of distributed system
 P2P does not distinguish clients and servers
 Instead all nodes are considered peers
 May each act as client, server or both
 Node must join P2P network
 Registers its service with central lookup service on
network, or
 Broadcast request for service and respond to requests
for service via discovery protocol
 Examples include Napster and Gnutella

37
Clustered Systems
 Clustering allows two or more systems to
share storage closely linked via a local area
network.
 Provides high reliability.
 Asymmetric Cluster (at least two servers: One
is on a standby mode while the other is
monitoring the other one. If one stops other
will work).
 Symmetric clustering: all N hosts are running
the application. They work together and
monitor each other)

38
Clustered Systems

39
Special-Purpose Systems
 Real-time embedded systems are much
prevalent form of computers
 Vary considerably, special purpose, limited
purpose OS, real-time OS
 Multimedia systems
 Streams of data must be delivered according to
time restrictions
 Handheld systems
 PDAs, smart phones with limited CPU, memory,
power
 Reduced feature set OS, limited I/O

40
Real-Time Systems
 Often used as a control device in a
dedicated application such as
controlling scientific experiments,
medical imaging systems, industrial
control systems, and some display
systems.
 Well-defined fixed-time constraints.
 Real-Time systems may be either hard
or soft real-time.

41
Handheld Systems
 Personal Digital Assistants (PDAs)
 Cellular telephones
 Issues:
 Limited memory
 Slow processors
 Small display screens.

PALM OS
Packet PC OS

42
Open-Source Operating Systems
 Operating systems made available in source-code
format rather than just binary closed-source
 Counter to the copy protection and Digital
Rights Management (DRM) movement
 Started by Free Software Foundation (FSF),
which has “copyleft” GNU Public License (GPL)
 Examples include GNU/Linux and BSD UNIX
(including core of Mac OS X), and many more

43
OS Installation Methods

44
Computer Startup
 bootstrap program is loaded at power-up or
reboot
 Typically stored in ROM or EEPROM, generally
known as firmware
 Initializes all aspects of system
 Locate and Loads operating system kernel into
memory
 OS then starts its first process “init” and wait for
some event to occur
 Occurrence of event is usually signaled with an
interrupt
 Either from Hardware or Software

46
Computer System Organization
 Computer-system operation
 One or more CPUs, device controllers, Memory
connected through common bus
 Concurrent execution on CPUs
 Devices competing for memory cycles

47
Computer-System Operation
 I/O devices & CPU 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 of devices
 I/O is from the device to the local buffer
 Device controller informs CPU that it has
finished its operation by using interrupts

48
Common Functions of Interrupts
 Interrupt transfers control to the interrupt
service routine
 through the interrupt vector, that contains
addresses of all the service routines
 Must save the address of interrupted
instruction
 Interrupt handling may be Sequential or
Nested

 An operating system is interrupt driven

49
Interrupt Handling
 Operating system preserves the state of the
CPU by storing values of registers and
program counter
 For Context Switching
 Then it determines which type of interrupt has
occurred
 Separate segments of code determine what
action should be taken for each type of
interrupt

50
I/O Structure
 Computers normally contain CPUs and Device
Controllers connected with Buses
 Each device controller is in charge of specific
type of device
More than one devices can be attached to single

device controller
 Device controller maintains a Local Buffer and a
set of special purpose registers
 Device controller is responsible for data movement
between Peripheral device and local buffer
 OS has a Device Driver for each device
controller

51
I/O Structure

52
Direct Memory Access (DMA) Structure
 Used for high-speed I/O devices
 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
 Useful for bulk data transfer
 CPU can perform other tasks during this time

53
Storage Structure
 Main memory – large storage media that CPU
can access directly, volatile
 Secondary storage – extension of main
memory that provides large nonvolatile
storage capacity
 Magnetic disks – rigid metal or glass platters
covered with magnetic recording material
 Disk surface is logically divided into tracks, which
are subdivided into sectors
 Disk controller determines the logical interaction
between device and computer

54
Storage Hierarchy
 Storage system is organized in hierarchy that
depends upon:
 Speed
 Cost
 Volatility

 Caching – copying information into faster


storage system;
 main memory can be viewed as a cache for
secondary storage

55
Caching
 Important principle, performed at many levels in a
computer (in hardware, operating system,
software, web servers)
 Information in use is copied from slower to faster
storage temporarily
 First the faster storage (cache) is checked to
determine if information is there
 If found, information used directly from the cache (fast)
 If not, data copied to cache and then used

 Cache smaller than storage being cached


 Cache size and replacement policy

56
Storage-Device Hierarchy

57
How a Modern Computer Works

A von Neumann
architecture
58
Computer-System Architecture
 Most systems use a single general-purpose
processor
 Systems also have special-purpose processors
 Multiprocessors systems are growing in use
 Also known as parallel systems, tightly-coupled
systems
 Advantages:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault
tolerance
 Two types of multiprocessor systems:
1. Asymmetric Multiprocessing (Client/Server)
2. Symmetric Multiprocessing (Peers)
59
Operating-System Operations
 Interrupts are mainly driven by hardware
 Software interrupts create exception or trap
 Division by zero, request for unauthorized memory
 Infinite loop, processes modifying each other or the
operating system

 Hardware supports two modes of operations


• User mode and kernel mode

 This Dual-mode operation allows OS to protect


itself and other system components

60
Operating-System Operations
 A special Mode-bit provided by hardware
 Provides ability to distinguish when system is running
user code or kernel code
 Some instructions designated as privileged,
 executable only in kernel mode
 System call changes user mode to kernel mode, and
return from call resets it to the user mode

61
Timer
 Timer to prevent infinite loop / process
monopolizing resources
 Set interrupt after specific period
 Operating system decrements counter
 When counter gets zero interrupt is generated
 Set up before scheduling process to regain control
or terminate program that exceeds allotted time

62
Process Management
 A process is a program in execution
 It is a unit of work within the system
 Program is a passive entity
 process is an active entity
 Process needs resources to accomplish its task
 CPU, memory, I/O, files
 Initialization data
 Process termination requires reclaim of any
reusable resources

63
Process Management
 Single-threaded process has one program
counter
 Specifying location of next instruction to execute
 Process executes instructions sequentially, one at
a time, until completion
 Multi-threaded process has one program
counter per thread
 Typically system has many processes, some
user, some operating system running
concurrently on one or more CPUs
 Concurrency by multiplexing the CPUs among the
processes / threads

64
Process Management Activities
 OS performs following activities for process
management:
 Creating and deleting both user and system
processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
 Providing mechanisms for deadlock handling

65
Memory Management
 All data and instructions must be in memory
in order to execute
 Memory management determines what is in
memory for optimizing CPU utilization and
response time to users
 Memory management activities
 Keeping track of which parts of memory are
currently being used and by whom
 Deciding which processes (or part of process) and
data to move into and out of memory
 Allocating and deallocating memory space as
needed

66
Storage Management
 OS provides uniform, logical view of
information storage
 Abstracts physical properties of storage devices to
define a logical storage unit i.e. file
 File is a collection of related information
defined by its owner
 Files are stored on medias with varying
properties
 Access speed, capacity, data-transfer rate, access
method
 OS maintains the File Management System

67
Storage Management
 File-System management
 Files usually organized into directories
 Access control on most systems to
determine who can access what
 OS activities include
 Creating and deleting files and directories
 Primitives to manipulate files and directories
 Mapping files onto secondary storage
 Backup files onto secondary storage

68
Mass-Storage Management
 Usually disks are used to store data for a long
period of time
 Entire speed of computer operations may depend
on disk subsystem and its algorithms
 OS activities
 Free-space management
 Storage allocation
 Disk scheduling
 Some storage need not be fast
 Tertiary storage includes optical storage, magnetic tape
 Still must be managed by OS or applications

69
Performance of Various Levels of Storage
 Movement between levels of storage
hierarchy can be explicit or implicit

70
Migration of Integer A from Disk to Register

 Multitasking environments must be careful to use most


recent value, no matter where it is stored in the storage
hierarchy
 Multiprocessor environment must provide cache coherency
in hardware such that all CPUs have the most recent value
in their cache
 Distributed environment situation even more complex

71
Protection and Security
 Protection – any mechanism for controlling access of
processes or users to resources defined by the OS
 Security – defense of the system against internal and
external attacks
 Huge range of security attacks, including denial-of-service,
worms, viruses, identity theft, theft of service
 Systems generally first distinguish among users, to
determine who can do what
 User identities (user IDs, security IDs) include name and
associated number, one per user
 Group identifier (group ID) allows set of users to be defined for
control management, then also associate group with each
process and file
 Privilege escalation allows user to change to effective ID with
more rights

72
Interrupts, Traps and Signals

 In case of interrupts and trap, the CPU invokes a piece of


code in the OS to service it, known as interrup service
routine (ISR) or trap service routine (TSR)
 In case of a Signal, the process can take one of the three
possible acions:
– Default action as defined by OS
– Ignore signal
– Take a programmer specified

73
Challanges of Time sharing systems

 Time sharing systems allows:


– Multiple users to use system
– Multiple process to run
– Interactivity
 Protection Errors
– Hardware protection issues
• Dual mode operation
• I/O Protection
• Main memory Protection
• CPU Protection

74

You might also like