sssops1516_5Final
Download
Report
Transcript sssops1516_5Final
Chapter Test 1
Marks: 20
1. Define batch, hard real time system, degree of
multiprogramming , background job, quantum
2. Draw diagram of OS, Batch OS, Distributed OS
3. Explain generations of computer
4. Define OS and list out any 8 services
BEST OF LUCK
SSS Foundation Course
Operating System(17512)
PPT Created and Developed by:
Prof. Suyog S. Dhoot
Lecturer (Information Technology),
K. K.Wagh Polytechnic, Nashik
Mobile No: 9762424330
Email id: [email protected]
Website: sssdhootkkwp.wordpress.com
Prof. Suyog S.Dhoot
3
Syllabus
Chapter
No
Name
Weightage
01
Introduction to OS
12
02
Operating System Structures
18
03
Process Management
22
04
Scheduling
20
05
File System and Memory
Management
Unix
20
06
08
Objectives
Definition of OS
Functions of OS
Generations of OS
Evolution of OS
Types of OS
Operating system
Operating system
An operating system act as an intermediary between the
user of a computer and computer hardware.
The purpose of an operating system is to provide an
environment in which a user can execute programs in a
convenient and efficient manner.
An operating system is a software that manages the
computer hardware.
An Operating system is concerned with the allocation of
resources and services, such as memory, processors,
devices and information.
Functions of os
Execution of program
Memory Management
Processor Management
File Management
Device Management
Job Accounting
Security
Error Detection
Control over system performance
Functions of os
Job Accounting : Time and Resources use by jobs and
users
Security : Providing unauthorized access to data
Error Detection : Error message and debugging
Control over system performance : Delay between
request of service and response from system
Device Management : i/o controller
Processor Management: traffic controller
GENERATIONS OF COMPUTER/
EVOLUTION of os
Generation
Year
Electronic
devices used
Types of OS and
devices
1
1940-1955
Vacuum tubes, Punch
card, paper tape
Plug boards
2
1955-1965
Transistors
Batch system
3
1965-1975
Integrated Circuit
(IC)
Multiprogramming
4
1975
Large scale
integration
PC
5
GENERATIONS OF COMPUTER
1st generation
1940-1955
Main electronic component is
vacuum tube
Used machine level language
Punch card used as input device
Speed milliseconds
ENIAC: Electronic Numerical Integrator and Calculator
30*50 feet long, 18000 tube, 30 ton weight
GENERATIONS OF COMPUTER
2nd generation
1955-1965
Main electronic component is transistor
Used assembly level language
Punch card used as input device
Speed microseconds
Less heat, FORTAN and COBOL used
IBM 1401, IBM 1620
GENERATIONS OF COMPUTER
3rd generation
1965-1975
Main electronic component is Integrated Circuit
Used assembly level language
Keyboard and Mouse used as input device
Speed Nano seconds
IBM 360, IBM 370
GENERATIONS OF COMPUTER
4th generation
1975-1990
Main electronic component is Microprocessor
Networking, GUI
Keyboard and Mouse used as input device
Apple, IBM PC
GENERATIONS OF COMPUTER
5th generation
1990
Artificial intelligence
Expert system
Nano technology
Batch OS
Program and Input data is called job where as group of
similar job called as batch.
Executing jobs in batch , reduce setup operation to once
and multiple programs can be executed with same setup
User do not intereact with computer directly. It will
submit job to software which reside in memory called as
monitor.
Functions of monitor:
Accepting jobs from user
Set up for first job
At end of job, terminate process and transfer to next job
At end of batch, terminate batch and transfer to new
batch
Batch OS
Advantages:
Setup time reduced
Performance increased
Useful for billing, Banking applications
Disadvantages:
Lack of interaction between user and job
Difficult to provide security and priority
CPU time not properly utilized
Real Time System
a system must produce output for given input within
specific given amount of time
Real time systems are usually dedicated embedded
systems.
They typically read from and react to sensor data.
The system must guarantee response to events within
fixed periods of time to ensure correct performance.
Types:
Hard: Response time is absolute value and task must
finish within deadline.
Soft: Response time is average and task may finish within
deadline or it may take more time.
Real Time System
Applications:
Medical Applications
Robotics and Automation
Web based applications
Virtual Reality
Direct interaction between user and application
Can lead to faults and security
Multiprogrammed os
In this multiple number
simultaneously but one at a time.
of
programs
User interaction is not possible
To reduce uniprogramming drawback an attempt
was made to keep cpu busy for all time
Numbers of programs executing simultaneously
is called as degree of multiprogramming
Multiprogrammed os
Advantages:
Throughput increased
Response time is good
Performance of CPU increase
Disadvantages:
Memory management required
Maintenance required and tracking of jobs required
multitasking
In this more than one program or task get executed
at same time or simultaneously
User interaction is possible
a task may be to watch movie, print document,
compile program etc.
It execute one job in foreground and many job in
background
Foreground job requires human interaction while
background jobs not required interaction
E.g. editing of document file along with printing of
another document file
Not reliable, not secure but cpu, i/o utilization is good
multiprocessor
It use two or more CPU within single computer
system.
All cpu shares system bus, memory and other
resources
Maximum work done in shorter period
Data in memory share by multiple processor instead
of making copies
Cpu communicate with each other as one cpu fails ,
system does not halt or fail
Symmetric : Same Processor share memory
Asymmetric: Different processor not share memory
multiprocessor OS
Advantages:
Throughput increased
Reliability increased
Hardware cost reduced
Disadvantages:
Complex in design
Expensive as use of cpu
os must support that processor
Distributed os
In this number of computers connected to each other
using cables for sharing and communication data
among each other.
Different applications, process or program avaliable
on different system.
It use to overcome centralized OS concept
Applications:
Student Information system
rain Reservation system
Types:
Vertical: Various levels of functionality and send
information to high level
Horizontal: All computer system at same level
Distributed OS
Advantages:
Throughput increased
Reliability increased
Hardware cost reduced
Disadvantages:
Complex in design
networking required
Time share OS
A time sharing system allows many users to share the
computer resources simultaneously.
Time sharing refers to the allocation of computer resources in
time slots to several programs simultaneously.
Equal time slots are provided to user for execution of programs
which also leads to the context switching, in which process shifts
control from one to another
In case any process does not complete its working within time
slot then extra time slot will not be given to it.
For example- you are running a process with a time slot of 5
seconds and in case process does not complete in 5 second and
requires 1 extra second then it will be executed in next execution
cycle but time slot will not be extended.
short period of time during that a user gets attention of the
CPU is known as a time slice or a quantum
Services of os
Program Execution
I/O operation
File Manipulation
Error detection
Communication
Resource allocation
Accounting
Protection/ Security
Services of os
Program Execution
OS provide facility to user to create program then it
loads in memory and finally get executed.
After successful execution, program get terminated
successfully
After unsuccessful execution , program terminated
abnormally by indicating errors
I/O operation
It provide facility to perform input/output operation
with hardware or different process.
e. g read or write data on I/O device.
Services of os
File Manipulation
Program needs to read a file or write a file.
The operating system gives the permission to the
program for operation on file.
Permission varies from read-only, read-write, denied
and so on.
Operating System provides an interface to the user to
create/delete files/directories.
Operating System provides an interface to create the
backup of file system.
Services of os
Error Detection
An error is one part of the system may cause
malfunctioning of the complete system. To avoid such
a situation the operating system constantly monitors
the system for detecting the errors.
Errors may occur in CPU, Memory, I/O devices or
programs
For each type of error, OS must take corrective step
to recover from that.
Services of os
Communication
exchange of information between processes
executing either on the same computer or on
different syste.ms tied together by a network.
Implemented via shared memory or message
passing.
Specific hardware or user program used for this.
Protection
Protection refers to mechanism or a way to control the access of
programs, processes, or users to the resources defined by a computer
systems.
OS ensures that external I/O devices are protected from invalid access
attempts.
OS provides authentication feature for each user by means of a password.
Services of os
Resource Allocation
Allocating resources to multiple users or multiple
jobs running at the same time.
Resource may be hardware – CPU, Memory, I/O
Device or software- Programs
It must handle situation in such manner that all user
get resources whenever they demand
Accounting
keep track of and record which users use how much
and what kinds of compute resources for account
billing.
It can be use to detect error or to add some
resources or for protection purpose.
System component
activities
OS breaks into modules or parts which perform
specific task
Process Management
Memory Management
File Management
I/O System Management
Secondary Storage Management
Networking Managment
System component
activities
Process Management
Process: Program in Execution state
Activities involve in handling process called process
management
Process is active entity which require resources for
execution
Activities:
Creation of user and system process
Suspending and resuming process
Mechanism
for
process
communication,
synchronization, deadlock handling
System component
activities
Main Memory Management
RAM is main memory present in CPU
Activities involve in handling memory called memory
management
Memory management require for smooth
functioning of System
Activities:
Tracking of memory
Deciding priority to allocate memory
Allocation and DEallocation of memory
System component
activities
File Management
File: Collection of programs and data
Activities involve in handling Files called File
management
Directory: Collection of Files
Activities:
Creation, deletion, updation of files and directories
Backup to secondary storage
File Manipulation
System component
activities
I/O System Management
It includes Hardware
Activities involve in handling I/O device called I/O
device management
Drivers required to operate I/O device
Activities:
Performing Buffering, Caching and Spooling
Memory management to devices
Effective utilization
Driver Support and hiding complexity of hardware
System component
activities
Networking Management
Computers are connected to each other for sharing
information is called network
Activities involve in networking called networking
management
Protocol used
Activities:
Mechanism to share data or resource
Mechanism to connect computers to each other
Providing security and permissions
Mechanism to detect fault
System component
activities
Secondary Storage Management
It includes CD, DVD, Flopy, PenDrive, HardDisk
Activities involve in handling
device called
management
Security mechanism required
Activities:
System call
The mechanism used by an application program to
request service from the operating system
System call available in assembly level or high level
language
System call are access using API
users do not need to write their own environment
for program development (editors, compilers) and
program execution .
Types System call
System calls for
Process or Job control
File Manipulation
Device management
Information management
Communication
Types System call
Process or Job control
End
Abort
Load
Execute
Create
Terminate
Suspend
Resume
Get and Set process attributes: id, state, priority
Wait for time, Event
Change the priority of process
Types System call
File manipulation
Create File
Delete File
Open File
Close
Read
Write
Reposition
Get File Attributes
Set File Attributes
Types System call
Device Management
Request device
Release device
Read
Write
Reposition
Get and Set device attributes: id, name, type, speed
Types System call
Information Management
Get Time
Set Time
Get system data
Set system data
Get and Set Process, File or Device attributes
Types System call
Communication
Create connection
Delete connection
Send message
Receive message
Transfer status information
Logically attach and detach remote device
Process state
Different process states are
New
Newly created process
Memory is not available so not ready for execution
Once called in life time
Ready
Process ready for execution waiting for cpu time
After getting cpu time it start execution
Running
Process which hold cpu time and start execution
In this program becomes process
Process state
Different process states are
Blocked
Process stop execution due to unavailability of I/O device or
event
Memory space occupied by process is released
After block state it goes to ready state
Terminated / Halted
After successful completion of process it enters into
terminated state
Unsuccessful completion also turns into terminated state by
indicating errors
After getting cpu time it start execution
Process state
Sr. No
System Call
Previous
State
Present
State
01
Enter
--
New
02
Admit
New
Ready
03
Dispatch
Ready
Running
04
Time-up
Running
Ready
05
Block
Running
Blocked
06
Wake-up
Blocked
Ready
07
Terminate
Running
Halted
Process CONTROL BLOCK
Process Control block is used for storing the collection of
information about the Processes and this is also called as the
Data Structure which Stores the information about the
process.
It created when process created and removed from memory
when process terminated.
Fields:
Process id , Process State, Process Priority
Register Save Area , Pointer to process memory
Pointer to other process, List of open files, Accounting
information, Pointer to other PCB
Scheduling queues
Ready Process Queue
Blocked Process Queue
Blocked and Swapped out ready process queue
schedulers
Long Term Scheduler
Short Term Scheduler
Medium Term Scheduler
Inter process
communication
Message Passing
Shared Memory
Context Switch
Transferring CPU control of one process to another process
All information must be stored in PCB
Operation on process
Process Creation
Initially process is created and 1 process can create another
process.
It form parent-child structure that looks like process tree
fork system call use to create process which create exact
duplicate copy
fork system call return integer number on successful creation
of process i. e 0 for child and >0 for parent
Each child process share address space of its parent
Each child process has its process id and parent process id
The exec call is a way to basically replace the entire current
process with a new program. It loads the program into the
current process space and runs it from the entry point.
Operation on process
Process Termination
Process can terminate its execution successfully or by
indicating errors
end, abort or exit system call use
Parent may terminate or killed child process due to
Child process use resources beyond limit
Parent not allowed to create process due to limit
Parent want to terminate
Parent process wait for its child to be get executed
Even if parent process terminate, child process continue its
execution
Operation on process
Process Suspension
Execution of process stop for some amount of time
May be insufficient memory
May be stop for some correction
Resume Process
Block Process
Wake-up Process
Dispatch Process
Destroy Process
threads
Light weight process which has separate path
of execution
Single process contains as many threads
Threads executed simultaneously
Multithreading: Multiple threads running
simultaneously
Each thread has thread ID, Register and
Program Counter
E.g. MS Word, Web Browser etc
Single thread vs multithreads
Benefits of thread
Responsiveness- Interactive System
Resource Sharing- Share resources of process
Economy- Cost effective as compare to process
Full Utilization- CPU utilization
types of thread
Kernel Thread
Kernel is program which connect application
program to I/O device, CPU or memory
Supported by OS
Kernel perform thread creation, scheduling
and management
Speed of creation is slow
Calling system call not affect entire process
E.g Windows NT, Linux
types of thread
User Thread
Supported by user and kernel not aware
user perform thread creation, scheduling and
management using thread libraries
Speed of creation is fast
Calling system call affect entire process
E.g Solaris
Multithreading model
Many to One
Maps many user level thread to kernel level
thread
Calling system call by user thread will block
entire process
Concurrency can not achieve as only one user
thread can access kernel thread at time
E.g Solaris green thread
Multithreading model
one to One
Maps one user level thread to one kernel level
thread
Calling system call by user thread will not
block entire process
Concurrency can achieve as one user thread
can access kernel thread at time
E.g Windows NT, Windows 2000
Multithreading model
Many to Many
Maps Many user level thread to Many or less
kernel level thread
Calling system call by user thread will not
block entire process
Concurrency can achieve at kernel level
thread
E.g Unix
scheduling
Process of allocating CPU to process known as
scheduling
Short term scheduler used for this
Main objective is that to kept CPU busy and full
utilization of CPU
All resourced must be scheduled before they use
It used for CPU and I/O device
Types: Preemptive Scheduling
Non Preemptive Scheduling
CPU & I/O burst cycle
Process execution is cycle of CPU execution and I/O
operation.
Process execution begins with CPU burst followed
by I/O burst upto process termination
At last it will use CPU burst
e. g Online Activities
CPU & I/O bound process
I/O bound process:
Process has very large I/O burst cycle and less CPU
burst cycle
Response time, Waiting time o execution time is
longer
I/O bound process:
Process has very large CPU burst cycle and less I/O
burst cycle
Response time, Waiting time o execution time is
small
CPU Scheduling decision
When a process switches from the running state to
the waiting state (for example, as the result of an I/0
request
When a process switches from the running state to
the ready state
When a process switches from the waiting state to
the ready state (for example, at completion of I/0)
When a process terminates
Preemptive scheduling
Process is interrupted to stop its execution and
allows other process to start execution
Higher priority process get chance for execution
early
less number of process get executed
Non Preemptive scheduling
Process continue there execution even if high
priority process arrives
Process may stop because of I/O request or
terminate or time slice end.
Not suitable for real time system
Large number of process get executed
Scheduling Criteria
CPU Utilization: CPU must be busy for all time and
will be utilized upto 100%
Throughput: Total process executed in particular
time or amount of work done by CPU.
It must be high for using scheduling algorithm
Turnaround Time: Time difference between
submission of process and completion of process.
TA time= Time on Waiting queue + Time on I/O
request queue + Time required for execution
Scheduling Criteria
Waiting time: amount of time process spend in
ready queue
Response time: time difference between submission
of job and first response time
Deadline: Amount of time given to process called as
deadline
deadlock
A set of blocked processes each holding resource and
waiting to acquire resource held by another process
in set.
In multiprogramming system it occur
E. g 2 tape drive
Dinning philosopher problem
Bridge
River
Job and experience
System model
Resource types (R1,R2……Rn)
e. g. cpu cycle, memory, I/O device
Each resource has Wi instances
each process utilize resources as follows:
Request -- Use -- Release
types of resources:
Non preemptable
preemptable
Conditions for deadlock
Mutual Exclusion: Process do not share resources
mutually and only 1 process can use resource at time
Hold and Wait: Process holding at least resource and
waiting to acquire another resource held by other
process
No preemtion: Resource can be released only
voluntarily by the process holding it, after that
process completed its task
Circular wait: There must exist a set {P0, P1, ..., Pn } of waiting
processes such that P0 is waiting for a resource that is held by P1, P1 is
waiting for a resource that is held by P2, …., Pn-1 is waiting for a resource
that is held by Pn, and Pn is waiting for a resource that is held by P0.
All 4 conditions are executed simultaneously to occur deadlock
Resource allocation graph
Graph is collection of set of vertices and edges
Vertices partitioned into two types:
1. Process
2. Resource
Edges are requesting edge and assignment edge
Request edge: Pi Rj
Assignment edge: Rj pi
Process
Resource
Resource allocation graph
Deadlock handling
Deadlock Avoidance
Deadlock Detection
Deadlock Prevention
Deadlock Recovery
Deadlock Ignorance
Deadlock prevention
To prevent from deadlock at least any 1 condition of
deadlock must be false
Mutual Exclusion: If every resource in the system can
be shared by multiple process .
Hold and Wait: Deadlock can be prevent by
prohibiting a process to wait for more resources
while already holding some resources.
At starting process must declare how many resource
it want and if all resources are available then OS
allocate resources.
Deadlock prevention
No preemption : If resource taken out forcibly from
process then deadlock can be prevent .
Circular Wait: A integer number allocated to resource
and in circular wait a process which requesting
resource must have resource with smaller number as
compare to number of resource that he want.
Deadlock avoidance
Additional prior information regarding resources of
process required
Process must give information regarding resources at
starting
Bankers / safety algorithm used to avoid deadlock
Bankers algorithm
New Process enters into system, it must declare
maximum number of instances of each resource type
that it may need.
OS must allocate resources if system is in safe state
otherwise process has to wait for allocation
let n be number of process and m be number of
resources
Bankers algorithm
Date Structure Requirement:
A. Available: A vector of length m indicate total
number of available resources of each type
B. Max: an n*m matrix define maximum demand of
each resource.
C. Allocation: an n*m matrix indicates number of
resources of each type currently allocated to each
process
D. Need: an n*m matrix indicates remaining resources
need of each process
Bankers algorithm
1. When request for resource made by process pi then
perform following actions:
2. If Request i<= Need i then got o step 3 otherwise
raise error
3. If Request i<= Available, go to step 4 otherwise wait
for resource
4. Available= Available- Request
Allocation: Allocation + Request
Need = Need - Request
5. If resulting resource allocation state is true then
resources allocated
Bankers algorithm
1. Process P0, P1, P2, P3, P4
2. Resource A-10, B-5 , C-7
Max
Allocated
Available
Process
A
B
C
A
B
C
P0
7
5
3
0
1
0
P1
3
2
2
2
0
0
P2
9
0
2
3
0
2
P3
2
2
2
2
1
1
P4
4
3
3
0
0
2
A
B
C
3
3
2
File
File is collection of related information that stored in
secondary storage such as magnetic tape, magnetic
disk etc.
File is sequence of bits, bytes, lines or records whose
meaning and type defined by user or creator
Each file has attributes which vary from one OS to
other OS
File attributes
Characteristics of file known as attribute of file
Name: Unique name associated with file through
which it get called.
Type: It may be text, executable, multimedia, sound
etc. type of file
Size: Size of file in bits, bytes or records
Location: Address of file that stored in secondary
storage
Protection: Access control information i.e read only
or write only
Date of creation: Date when file created
File attributes
Date of modification: recent changes done with file
data.
User: Name of user who create file
Last use: Date and time at which last time user
access the file
Usage count: Number of user currently using same
file
File operations
Creation of file: New file can be created by user if
space in secondary storage is available and entry in
disk must be made.
Write: Name and Data required
Read: Name and Storage memory required
Rewind: Changing position of pointer within file
Close
Delete
File types
Type
Example
Use
Executable
.exe, .com
Run functions
Source
.c, .cpp , .java
Source file
Object file /
Batch file
.obj , .o
Interpreter files
Text
.txt , .doc
Text or word files
Library files
.lib , .dll
Library files for
programmer
Archive
.zip, .rar
Compress file
Multimedia
.mp4, .mp3
Audio and Video file
Ordinary, Directory and Special Files (system device)
File system structure
Organization of file in OS to interact of files with users
and applications
ACCESS METHOD
Method which are used to access files are known as
access method.
Searching of file can be done through access method
Different access method:
Sequential Access
Direct Access
ACCESS METHOD
Sequential Access:
File organized as collection of fixed length record and
each record has fixed number of fields
operations are provided:
move forward, move backward and reset
to find nth record , (n-1) record to be scanned until
that record has been found
ACCESS METHOD
Sequential Access:
Advantages:
Useful of tape based system
no data structure available
Disadvantages:
Very slow and time consuming
Complex to search large files
Only forward and backward operation possible
ACCESS METHOD
Direct access:
Based on random access device in which file consider
as collection of block.
Block is logical quantity which is of size multiple of 512
bytes.
Files are access using blocks without any head
movement and head movement require only when
head moves from last block to first block
Operation: read n, write n, rewind n
Accessing time is fast and require less time for
operation
swapping
Removing suspend or preempted process from
memory and bringing back is called swapping
Transferring process from memory to disk called as
swapping out
Transferring process again from disk to memory called
as swapping in
Swapping used for priority based scheduling algorithm.
If higher priority process arrives and want memory
then memory manager swap out lower priority process
Again lower priority can swap back and its execution
get continued
Swapping algorithm coordinate amongst information, process and memory management.
Directory structure
Organization of files maintained on secondary storage
in particular fashion known directory structure
Types:
Single Level
Directory structure
Types:
Double Level
Free space managment
Technics
Bitmap Vector
Linked List
partitioning
Dividing memory into multiple sections of same or
different size
It done at time of system generation and then can not
be changed
System generation means specifying requirements of
OS
Memory used by OS and User
Types:
Static or Fixed
Dynamic or Variable
Static or fixed partitioning
It done at time of system generation and then it can not be
changed
Initially all partitions are free and when process loaded into
memory then status changed from free to allocated
Starting address of each partition is fixed
Partition Description Table maintains which describe status of
each partition
Static or fixed partitioning
Allocation of partition to process done in 2 ways
Multiple Queue: Depending on number of partition,
number of queues are maintained. For n partition, n
queues are maintained
Each queue maintain size of process and based on size
process transferred to queue and then partition
Single Queue: Only one queue is maintained and based
on size it transferred to partition
Static partitioning works fast but memory wastage
occur as some part of partition will not be use by otger
process. It called as internal fragmentation
Static or fixed partitioning
Dynamic or variable partitioning
It done at running time of creation of process and then
it can be changed
Whenever process wants memory then its equal size
partition created
Starting address of each partition is not fixed
Partition Description Table can not be maintains but
bitmap or linked list describe status of each partition
No internal fragmentation