Subject Name: Subject Code: 15EC553 Prepared By: Ms. Kavitha, Ms. Kripa, Ms. Sheher Banu S Department: ECE Date: 09.0917
Subject Name: Subject Code: 15EC553 Prepared By: Ms. Kavitha, Ms. Kripa, Ms. Sheher Banu S Department: ECE Date: 09.0917
Department: ECE
Date: 09.0917
9/9/2017
MODULE 1
Introduction to Operating
Systems
9/9/2017
TOPICS
• OS
• Goals of an OS
• Operation of an OS
• Computational Structures
• Resource allocation techniques
• Efficiency, System Performance and User Convenience
• Classes operating System
• Batch processing
• Multi programming
• Time Sharing Systems
• Real Time and distributed Operating Systems
9/9/2017
Abstract Views of an OS
• What is an OS?
– Abstract views
• To a school/college student: Software that permits access to
the Internet
• To a programmer: Software that makes it possible to develop
programs on a computer system
• To a user of an application package: Software that makes it
possible to use the package
• To a technician in a computerized chemical plant: invisible
component of a computer system that controls the plant
9/9/2017
9/9/2017
Abstract Views of an OS
• User’s perception about OS depends on;
– Purpose for which a computer is being used.
– Computing environment in which the computer system is used.
– Degree of identity of the computer system with the purpose
being served.
9/9/2017
9/9/2017
Abstract Views of an OS
• Hence, user perceives an OS- as the software that helps
him in achieving an intended use of the computer system,
other capabilities of the computer system and its
environment do not seem to matter.
• OS is a means of achieving an intended purpose in the
simplest and fastest possible manner.
9/9/2017
Uses of Abstract Views
9/9/2017
Abstract Views of an OS
• Operating system designer also has an
abstract view
9/9/2017
Logical and Physical views of execution of a
program
9/9/2017
Goals of an OS
• Fundamental goals of an operating system
– Efficient use of computer resources
– User convenience
• Effective utilization
9/9/2017
OS & Effective utilization of computer systems
• User-centric considerations
– User convenience, fast service to user requests.
– Interactive computing & time critical applications.
• System-centric considerations
– Efficient use of the system.
– Requires good resource allocation policies.
– Non-interactive data processing applications.
• Two aspects in efficient use of resources;
– Overhead: Resource utilization during OS operation
– Poor efficiency:
• Over allocation of resources to programs
• Not able to allocate free resources to programs that need
9/9/2017
them
Efficient Use
• Resources: Memory, I/O devices, CPU.
• OS ensures efficient use of memory, CPU, and I/O devices
– Poor efficiency can result if a program does not use a resource
allocated to it
• OS can monitor use of resources to ensure efficiency
• OS itself consumes CPU and memory resources, which constitutes
overhead
– It reduces resources for user programs
• OS uses policies that ensure efficiency
9/9/2017
User Convenience
9/9/2017
Operation of an OS
9/9/2017
Common tasks performed by OS
9/9/2017
Programs- Computational
Structures
• A configuration of one or more programs that work
towards a common goal.
– A single program
– Co-executing programs
9/9/2017
Computational structures & OS
responsibilities
9/9/2017
Computational Structures - Single
program
• Simplest computational structure.
9/9/2017
9/9/2017
Computational Structures –
Sequence of single programs
• Sequence of single programs.
9/9/2017
9/9/2017
Example; Steps in execution of a
sequence of programs in MS DOS
C
Compiler Linker demo
9/9/2017
9/9/2017
Computational Structures – Co-
executing programs
• User initiates co-executing programs by indicating their
names in a single command.
9/9/2017
9/9/2017
Example; Co-execution of programs
in Unix
• Unix command to count the number of unique names in a file
names : cat names | sort | uniq| wc -1
• Types of resources;
– System resources
– User-created resources
9/9/2017
9/9/2017
Resource Allocation Strategies
– Partitioning of Resources
9/9/2017
9/9/2017
Resource Partitioning Approach
• Static allocation.
• Simple to implement.
• OS decides a priori what resources should be allocated to a
user program.
• Allocation is made before execution of a program begins.
• Allocation is based on perceived needs of a program rather
than its actual needs.
• Disadvantage:
– Lacks flexibility, wastage of resources.
– Inability of OS to grant additional resources to a
program during its execution.
9/9/2017
9/9/2017
Pool-based Approach
• Dynamic allocation
9/9/2017
9/9/2017
Resource Allocation Table
9/9/2017
9/9/2017
Sharing of Resources
• Sequential Sharing
– Resource is allocated for exclusive use by a program.
• Concurrent Sharing
– Two or more programs can concurrently use the same
resource.
9/9/2017
9/9/2017
• Deallocation of resources:
– After program termination
or
– By force
• to ensure fairness in its utilization by programs
or
• to retain system-level goals – Resource Preemption.
9/9/2017
9/9/2017
Sharing of Resources
CPU Sharing
Memory Sharing
Disk Sharing
9/9/2017
9/9/2017
CPU Sharing
• CPU sharing can be done only in sequential manner.
9/9/2017
9/9/2017
Scheduling
9/9/2017
9/9/2017
Memory Sharing
• Parts of memory can be treated as independent resources.
• Partitioning – Simple
9/9/2017
9/9/2017
Memory Allocation
9/9/2017
9/9/2017
Disk Sharing
• Different parts of a disk can be treated as independent resources.
• Partitioning – Simple
9/9/2017
9/9/2017
Virtual Resources
• Fictitious resource – an illusion supported by an OS through use
of a real resource.
9/9/2017
9/9/2017
Security and Protection
• Security counters threats of interference or illegal use
posed by persons/programs outside OS control
– Authentication: only registered user can use a computer
system
• Protection counters threats posed by users of an OS
9/9/2017
9/9/2017
Security & Protection
9/9/2017
9/9/2017
Security and Protection
• Intruders are outsiders who can cause
interference
– May use or create malicious programs
• Trojan horses
• Viruses
• Worms
• Methods of addressing security threats
– Authentication techniques
– Plugging security holes
9/9/2017
9/9/2017
Efficiency, System Performance, and Use
Convenience
9/9/2017
9/9/2017
System performance
• It is typically measured as throughput.
9/9/2017
9/9/2017
User service
• It is a measurable aspect of user convenience.
9/9/2017
9/9/2017
User service
• The turn-around time of a job, program, process is the
time since its submission for processing to the time its
results become available to the user.
9/9/2017
9/9/2017
Measuring Efficiency, System Performance,
and User Convenience
9/9/2017
9/9/2017
Classes of OS : Key features
9/9/2017
9/9/2017
Efficient Use & User Convenience in different OS classes
9/9/2017
9/9/2017
Batch Processing Systems
• Introduced to avoid CPU time wastage.
9/9/2017
9/9/2017
Batch Monitor
• Batch processing is implemented by the kernel – called Batch
Monitor.
• It resides in one part of the computer’s memory (system area),
remaining part of the memory (User area) is used for current job
of the batch.
9/9/2017
9/9/2017
Batch Processing OS
• Batch processing OS used the notion of Virtual devices to conserve
the CPU time of a powerful computer system.
9/9/2017
9/9/2017
Batch Monitor functions
• Scheduling
• Memory management
9/9/2017
9/9/2017
Batch Processing OS – Control statements & Command processor
9/9/2017
9/9/2017
2. Multiprogramming
9/9/2017
9/9/2017
Operation of a multiprogramming OS
9/9/2017
9/9/2017
Architectural Support for Multiprogramming
• Memory Protection
9/9/2017
9/9/2017
Architectural Support for Multiprogramming
9/9/2017
9/9/2017
• CPU modes of operation:
– User Mode (P=0)
– Privileged Mode (P=1)
• Privileged instructions
9/9/2017
9/9/2017
Architectural Support for Multiprogramming
9/9/2017
9/9/2017
Multiprogramming – User Service
9/9/2017
9/9/2017
Functions of the Multiprogramming Kernel
1. Scheduling (priority based)
2. Memory Management
3. I/O Management
Protection:
9/9/2017
9/9/2017
Concepts/Techniques to optimize Throughput in multiprogramming
9/9/2017
9/9/2017
Program Mix
• Let m=2, prog1 & prog2 – both CPU-bound.
– I/O subsystem is underloaded.
– Periods of concurrent CPU & I/O activities are rare.
– Hence, throughput is low.
9/9/2017
9/9/2017
Program Priority & Preemption
• Priority: is a tie-breaking notion used in a scheduler to
decide which request should be scheduled on the server
when many requests await service.
9/9/2017
9/9/2017
Assignment of Program Priorities
• Kernel assigns priorities to programs (CPU-bound / I/O-bound).
9/9/2017
9/9/2017
Higher priority to CPU-bound programs:
9/9/2017
9/9/2017
Observations
• CPU utilization is reasonable.
• I/O utilization is poor.
• Periods of concurrent CPU & I/O activities are rare.
• If m>2
– m= 3 (CPU-bound) prog3 Priority between Progcb &
progiob.
– m=3 (I/O-bound) prog4 –lowest priority.
9/9/2017
9/9/2017
Higher priority to I/O-bound programs:
9/9/2017
9/9/2017
Observations
• CPU utilization is reasonable.
• I/O utilization is reasonable.
• Periods of concurrent CPU & I/O activities are
frequent.
Advantage:
• System throughput can be increased by adding more
programs.
9/9/2017
9/9/2017
• Hence, assigning higher priority to I/O bound programs leads to good
throughput.
• It also enables the OS to combat poor throughput in the system by
increasing the degree of multiprogramming.
9/9/2017
9/9/2017
Degree of Multiprogramming
9/9/2017
9/9/2017
Time Sharing Systems
• Batch processing & Multiprogramming – non-interactive
computing environment, hence poor User Service.
• Interactive computing environment: Quick service to user
requests.
9/9/2017
9/9/2017
Time Sharing – User Service
9/9/2017
9/9/2017
Time Sharing – Scheduling
• All users must get an equal opportunity to present their
computational requests and have them serviced.
• Also each user must receive reasonable service.
1. Programs are not assigned priorities.
2. Every request receives OS attention without
unreasonable delays.
9/9/2017
9/9/2017
Round Robin Scheduling
• When a user makes a computational request to his program, the
program is added to the end of a scheduling list.
• Scheduler always removes the first program from the scheduling list
and gives the CPU to it.
• When the user makes another request, the program is once again
added to the end of the scheduling list.
9/9/2017
9/9/2017
Time Slicing
9/9/2017
9/9/2017
Round Robin Scheduling with Time Slicing
9/9/2017
9/9/2017
Time Sharing Kernel
• Time Slicing is implemented by the time sharing kernel
using interval timer.
9/9/2017
9/9/2017
Algorithm showing actions of Time Sharing
Kernel;
1. Select the first program in the scheduling list for execution.
Let the selected program be P. Remove P from the
scheduling list.
2. Load the value of the time slice into the interval timer.
3. Start execution of program P on the CPU.
4. If P initiates an I/O operation, go to step 1 to schedule
another program for execution.
5. When a timer interrupt occurs, preempt P and add it at the
end of the scheduling list. Go to step 1.
9/9/2017
9/9/2017
9/9/2017
9/9/2017
Response Time
CPU Efficiency
9/9/2017
9/9/2017
Actual response time may be different time from the values
predicted by the formula.
Reasons:
9/9/2017
9/9/2017
9/9/2017
9/9/2017
Timesharing scheduling, Time slice =10msec
9/9/2017
9/9/2017
Memory Management
• To use the CPU idle time, the system can service few more
user programs.
9/9/2017
9/9/2017
• Inactive program: A program which is neither executing on
the CPU nor performing an I/O operation.
1. Active programs.
9/9/2017
9/9/2017
Real Time Systems
• Real time application: A program that responds to
activities in an external system within a maximum time
determined by the external system.
9/9/2017
9/9/2017
Response requirement of a system: indicates the largest
value of response time for which the system can
function perfectly.
Timely Response: whose response time is smaller than
the response requirement of the system.
Deadline of an action in a real time application is the
time by which the action should be performed.
9/9/2017
9/9/2017
Real Time Applications
• Missile guidance
• Multimedia systems
9/9/2017
9/9/2017
Distributed Operating System
9/9/2017
9/9/2017
Concepts/Techniques
9/9/2017
9/9/2017
MODULE 2
Process Management
9/9/2017
TOPICS
• OS View of Processes
• PCB
• Fundamental State Transitions
• Threads
• Kernel Level Threads
• User Level Threads
9/9/2017
OS View of a Process
Process is an execution of a program.
Definition: A process is comprised of six components:
(id, code, data, stack, resources, CPU state)
Where;
id – a unique name/id assigned to program execution.
Code – data and files used in the program’s execution.
Resources – set of resources allocated by the OS.
Stack – Contains parameters of functions and procedures
called, and their return addresses.
CPU state – comprised of contents of PSW fields and the
CPU registers.
9/9/2017
9/9/2017
Controlling Processes
9/9/2017
9/9/2017
Components of Process Environment
9/9/2017
9/9/2017
Fields of Process Control Block
9/9/2017
9/9/2017
Fundamental functions of Kernel to
control processes:
• Scheduling
• Dispatching
• Context save
9/9/2017
9/9/2017
Process States and Transitions:
9/9/2017
9/9/2017
Fundamental state transitions for a process:
9/9/2017
9/9/2017
Suspended Processes:
9/9/2017
9/9/2017
Threads:
A program execution that uses the resources of a process.
9/9/2017
9/9/2017
Advantages of Threads:
9/9/2017
9/9/2017
Implementation of Threads:
9/9/2017
9/9/2017
Kernel Level Threads
9/9/2017
9/9/2017
User Level Threads:
9/9/2017
9/9/2017