0% found this document useful (0 votes)
135 views115 pages

Subject Name: Subject Code: 15EC553 Prepared By: Ms. Kavitha, Ms. Kripa, Ms. Sheher Banu S Department: ECE Date: 09.0917

This document provides an introduction to operating systems. It discusses the goals of an OS which are efficient use of computer resources and user convenience. When these goals conflict, the OS designer makes tradeoffs. The document then covers topics like the operation of an OS, computational structures like single programs, sequences of programs, and co-executing programs. It also discusses resource allocation techniques like partitioning and allocating from a pool. Specific resources like CPU, memory, and disk are described in the context of sharing.

Uploaded by

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

Subject Name: Subject Code: 15EC553 Prepared By: Ms. Kavitha, Ms. Kripa, Ms. Sheher Banu S Department: ECE Date: 09.0917

This document provides an introduction to operating systems. It discusses the goals of an OS which are efficient use of computer resources and user convenience. When these goals conflict, the OS designer makes tradeoffs. The document then covers topics like the operation of an OS, computational structures like single programs, sequences of programs, and co-executing programs. It also discusses resource allocation techniques like partitioning and allocating from a pool. Specific resources like CPU, memory, and disk are described in the context of sharing.

Uploaded by

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

Subject Name: OPERATING SYSTEM

Subject Code: 15EC553

Prepared By: Ms. Kavitha, Ms. Kripa, Ms. Sheher Banu S

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.

• Student : Internet browsing.


• Programmer: Program development.
• Person using application package: to use the package.
• Technician: views as everything in the control system of the plant.

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

• OS is a collection of routines that facilitates execution


of user programs and use of resources
9/9/2017
Logical & Physical Organization
• Three important entities from programmer’s point of
view;
– a file, a Program and an I/O device.
• Logical view – Abstract view of an entity.
• Physical view – Real view of an entity.

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

• When these goals conflict, designer makes a


trade-off for
– Efficient use
– 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

– A sequence of single programs

– Co-executing programs

9/9/2017
Computational structures & OS
responsibilities

9/9/2017
Computational Structures - Single
program
• Simplest computational structure.

• Consists of execution of a program on a given set of data.

• Program can either be sequential or concurrent.

9/9/2017
9/9/2017
Computational Structures –
Sequence of single programs
• Sequence of single programs.

• Each single program in the sequence is initiated by the


user through a separate command.

• A program is executed only if the previous program in the


sequence is executed successfully.

• Inputs & outputs are hence interfaced/interlinked.

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.

• All Programs execute at the same time and interact with


one another during their execution.

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

• 4 co-executing programs ; cat, sort, uniq, wc

• | : symbol for a unix pipe. It sends output of one programs as input


to another program.

• Passing results from one program to another is the responsibility of


OS.

• All co-executing programs terminate together.


9/9/2017
9/9/2017
Resource Allocation
• Resource allocation function performs binding of one or more
resources with a requesting program.

• It also deallocates resources from a program and allocates them to


another programs.

• Allocation & deallocation of resources - Resource sharing

• Resource protection : Function that prevents mutual interference


between users sharing a set of resources.

• Types of resources;
– System resources
– User-created resources
9/9/2017
9/9/2017
Resource Allocation Strategies

– Partitioning of Resources

– Allocation from a pool

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

• OS maintains a common pool of resources and allocates


from this pool whenever a program requests a resource.

• Allocation takes place during execution of a program.

• Better resource utilization – as it avoids wastage of


allocated resources.

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.

– After deallocation, it is marked free in the resource table.

– Then it can be allocated to another 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.

• Resource Preemption - forced deallocation of CPU


• Preempted program - A program that loses the CPU in
this manner

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.

• Only one program at a time.

• Other programs have to wait for their turn.

• Scheduling: Function of deciding which program should


be given the CPU and for how long.

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 & pool based allocation approach can be used


to manage memory.

• Partitioning – Simple

• Pool based – better use of memory-no wastage

• Swapping – Memory preemption

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 & pool based allocation approaches are feasible.

• Partitioning – Simple

• Pool based – better use of memory-no wastage

• Disk preemption is not practiced by OS. Users can preempt their


disk areas by copying their files onto tape cartridges.

9/9/2017
9/9/2017
Virtual Resources
• Fictitious resource – an illusion supported by an OS through use
of a real resource.

• An OS uses same real resource to support several virtual


resources.

• A virtual device, in operating systems, refers to a device file that


has no associated hardware.

• A virtual device mimics a physical hardware device when, in fact,


it exists only in software form. Therefore, it makes the system
believe that a particular hardware exists when it really does not.
9/9/2017
9/9/2017
• Virtual Memory is a space where large programs can store
themselves in form of pages while their execution and only the
required pages or portions of processes are loaded into the main
memory.

• A virtual printer is not really a printer at all; it is a piece of


software installed on your computer.

• Virtual Machines: created by an OS by partitioning the memory


and I/O devices of a real machine.

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.

• Definition -The throughput of a system is the number of


programs, jobs, processes or sub requests completed by it
per unit time.

9/9/2017
9/9/2017
User service
• It is a measurable aspect of user convenience.

• It indicates how a user’s computation has been treated by


the OS.

• Measures of user service:


– Turn-around time (for non-interactive computing environment)

– Response time (for interactive computing environment)

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.

• The response time provided to a sub request is the time


between the submission of the sub request by a user and
the formulation of the process’s response to it.

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

• Batch processing Systems – processes one user program at


a time.
• Multiprogramming Systems – processes many user
programs in an interleaved manner.
• Time sharing Systems – processes many programs over the
same period of time.
• Real time Systems – Dedicated to a single time critical
application.
• Distributed Systems – Provides resource sharing across the
boundaries of computer systems.
9/9/2017
9/9/2017
Punched cards
• Computer systems used punch cards as a primary input medium.
• Each user prepares his job on this off-line device and submits it to the
computer operator.
• A program & its data consisted – a deck of cards.
• Programmer submits a programmer at a counter in a computer center.
• Execution of the program would be set up by computer operator.

9/9/2017
9/9/2017
Batch Processing Systems
• Introduced to avoid CPU time wastage.

• Operates in a strict one-job-at-a-time manner.

• It is the execution of a series of programs in a job on a computer


without manual intervention (non-interactive).

• A Batch is a sequence of user jobs formed for the purpose of


processing by a batch processing OS.

• Each job in a batch is independent of other jobs in the batch.

• Jobs belong to different users.

• The users of a batch operating system do not interact with the


computer directly.
9/9/2017
9/9/2017
Batch Processing OS
Computer operator

 forms a batch by organizing a set of user jobs in a sequence.

 Insert special marker cards to indicate start and end of a batch.

 Submit a batch as a unit for processing by batch processing OS.

Primary function of batch processing OS:

 Service the jobs in a batch one after another without operator’s


intervention.

 Operator needs to intervene only at the start and end of a batch.

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.

• Virtual I/O devices – tapes or disks in place of punched cards &


printers.
– A program records a batch of jobs on magnetic tapes.
– Process these jobs.
– Write the results on another magnetic tape.
– Another program prints the contents of this tape.

• Two spooling operations were performed;


– Inspooling
– outspooling
9/9/2017
9/9/2017
Batch Processing OS – User Service

• Turn-around time used to quantify user service.

• Turn around time of a job, jobi in a batch includes;

– Time until a batch is formed.

– Time spent in executing all jobs of the batch.

– Time spent in printing and sorting the results


belonging to different jobs.
• Service to individual users deteriorates.
9/9/2017
9/9/2017
Batch Processing OS – User Service

9/9/2017
9/9/2017
Batch Monitor functions

• Scheduling

• Memory management

• Sharing & protection

Protection problems in card based systems –

Source : input card reader

9/9/2017
9/9/2017
Batch Processing OS – Control statements & Command processor

9/9/2017
9/9/2017
2. Multiprogramming

• Concurrency of operation between CPU and I/O


subsystem.
• OS can put many user programs in the memory and let
the CPU execute instructions of one or more program
while the I/O subsystem is busy with an I/O operation of
another program

9/9/2017
9/9/2017
Operation of a multiprogramming OS

9/9/2017
9/9/2017
Architectural Support for Multiprogramming

• DMA (Direct Memory Access)

• Memory Protection

• Privileged mode of CPU

9/9/2017
9/9/2017
Architectural Support for Multiprogramming

• DMA – makes multiprogramming feasible.

• Memory protection – Prevents mutual interference between


programs.

• Privileged mode of CPU – provides a method of implementing


memory protection and other measures to avoid interference
between programs.

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

• Turn-around time – Depends on the number of


jobs in the system and relative priorities assigned
to different jobs by the scheduler.

9/9/2017
9/9/2017
Functions of the Multiprogramming Kernel
1. Scheduling (priority based)

2. Memory Management

3. I/O Management

Protection:

• Memory protection hardware is used to prevent


mutual interference.

• Non-privileged mode of operation of CPU


9/9/2017
9/9/2017
Performance of a Multiprogramming
System
• Throughput: Ratio of the number of programs processed and
the total time taken to process them.
• n- number of programs
• to- start time
• tf- end time
• Throughput = n / (tf - to)

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.

• Throughput will be high when both programs progress concurrently.

• Program mix – a practical way to improve the throughput.


– Contains some CPU-bound programs and some I/O-bound programs.
– Progcb: CPU-bound program
– Progiob: I/O-bound program.

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.

• This leads to preemption of a low priority program when


a high priority program becomes ready to use the CPU.

• Preemption: is the forced deallocation of the CPU from a


program.

9/9/2017
9/9/2017
Assignment of Program Priorities
• Kernel assigns priorities to programs (CPU-bound / I/O-bound).

• This assignment influences the system throughput.

• Priority assignment rule; In multiprogramming systems, I/O-


bound programs should have higher priority than CPU-bound
programs.

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

• Response Time (rt): Time taken to service a sub request.

• Good rt required during program development which leads to


an improvement in the productivity of the user.

Design principles & techniques to get good rt;

– Designing an interactive user interface.

– New scheduling & memory management techniques.

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.

 Round Robin Scheduling


 Time Slicing

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 a program finishes computing its response to a request, it is


removed from the CPU and the first program in the new list is
selected for execution.

• 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

• Used to prevent monopolization of the CPU by a program.

• Time Slice: Largest amount of CPU time any program can


consume when scheduled to execute on the CPU.

• Time Slicing: Implementation of time slice.

• A program exceeding this time slice limit is preempted.

• Preempted program is added to the end of the scheduling list.

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.

• Interval timer consists of a register: Timer Register.

• Timer Register stores the time interval in hours, minutes


& seconds.

• A Timer Interrupt is raised when the contents of the


timer register becomes zero (timer interval elapsed).

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:

• Value of rt may be smaller than that predicted:


– All users may not have made requests to their programs.
– Hence,
• rt would not be influenced by n.
• It would be influenced by the number of active users(na), na <
n.

• User requests do not require exactly CPU seconds to produce a


response.
• So, relationship of response time, efficiency with time slice is more
complex than seen in formula.
9/9/2017
9/9/2017
Influence of time slice on response
time

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.

• Large memory is required.

• Solution: Swapping, whereby a computer can support a large


number of users without having to possess a large memory.

• Swapping: A technique of temporarily removing inactive


programs from the memory of a computer system.

9/9/2017
9/9/2017
• Inactive program: A program which is neither executing on
the CPU nor performing an I/O operation.

• Active program: Which executes on the CPU while others


perform I/O.

• The programs existing in the memory are classified into three


categories;

1. Active programs.

2. Programs being swapped out of the memory.

3. Programs being swapped into the memory.


9/9/2017
9/9/2017
A schematic of Swapping

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.

• If the application takes too long to respond to an


activity, a failure can occur in 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

• Command & control applications like


– Air traffic control

– Data sampling & data acquisition systems like


• Display systems in automobiles

• Multimedia systems

• Reservations & banking systems.


9/9/2017
9/9/2017
Types of Real Time Systems
• Hard Real time systems:
– Dedicated to processing real time applications.
– Meets the response requirement of an application
under all conditions.
 Ex: Guidance & control applications.
• Soft Real time systems:
– Makes best effort to meet the response requirement of
a real time application but cannot guarantee that it will
be able to meet it under all conditions.
 Ex: Multimedia applications, Reservation & banking
applications.
9/9/2017
9/9/2017
Features of Real Time OS

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:

• Kernel Level Threads


• User Level Threads
• Hybrid 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

You might also like