Beruflich Dokumente
Kultur Dokumente
CHAPTER 1
OPERATING SYSTEM
An Operating system is a computer program, which acts as an intermediary
between the user of the computer & the computer hardware.
Application program
Operating system
Hardware
User are developing & using the application program. This application program
running or execute hard with the use of operating system.
1
2nd SEM B.Sc.
2. Spooling:
Spooling is a method to supplies the job to the O/P device continuously
without any miss for this tech we need following setup.
Disk
The above fig. Disk is a memory its having high capacity buffer. It receives
the data or job from card reader & supplies the data or job to printer directly from
the buffer.
It decreases the idle time of CPU & O/P device
2
2nd SEM B.Sc.
P1 P2 P3 I/O
3
2nd SEM B.Sc.
4
2nd SEM B.Sc.
System calls: -
System calls provides the system service using system program. This
provides the interface between a process & the operating system.
Information or parameters may be passed to system calls using different methods.
The various system calls are:
1. System calls for the process management
End, abort a process, load & execute a process, create & terminate the
process.
2. System calls for the file management: -
Create or delete a file.
Open, read, write & close a file.
3. System calls for the device management:-
Request device, release device,
Logically attach or detach devices.
Get or set a device attributes.
5
2nd SEM B.Sc.
System programs: -
The O.S. also contants a set of program called system program. The main aim of
these programs is to simplify user interaction with the system.
System program are divided into different categories:
File manipulation,
Status information,
File modification, programming language support,
Communication, application program,
Command interpreter.
6
2nd SEM B.Sc.
CHAPTER -2
PROCESS MANAGEMENT
States of a Process:
The process (program) may be executed in various steps. This step of
process activity is called as states of a process.
The process state diagram explains the process states.
Accepted
New Interrupt
Exit
Ready
Running
I/O complete I/O Wait
Wait
Remainder
New state: In this state passive program has to be converted as dynamic activity
called process in this state process is created.
Running: In this state it executes a sequence of instructions & may go the wait
(remainder) state. [Only one process running at a time].
Waiting: The process is waiting for the occurrence of some event such as the
completion of an I/O operation.
7
2nd SEM B.Sc.
Process 2
Execution Process 1
Scheduling of process:
Save register
Reload register
Execution
8
2nd SEM B.Sc.
Scheduling queues:
In a multiprogramming environment, Whenever a process is created it is
Immediately put into ready queue.
Time slice
completed
Wait for
Interrupt
interrupt
CPU executes the sequence of events. Which goes through a cycle, which includes
a CPU execution & I – O wait.
Once the process is allocated the CPU & is executing. One of the several
events could occur.
Process could given an I –O request & placed in I/O queue.
Process could create a new sub process & wait for its termination.
Process could be removed by using interrupt signals.
Schedulers: -
The choice or selection of the process and its corresponding queue is done
by that part of the O.S. called Scheduler.
Schedulers are of different types.
1. Long Scheduler.
2. Short term scheduler.
9
2nd SEM B.Sc.
Long term scheduler selects job from the job pool and load it into the
memory for execution. Short term scheduler selects the process that is already in
the ready queue for execution.
Short term
Lowest Ready queue
Scheduler CPU
Time
Scheduler I/O waiting queue
I/O
Context switch: -
In a multiprogramming environment it is necessary to move from one
process to another. Switching the CPU to another process required saving the
state of the old process & loading the saved state for the new process. This is
called as Context switch.
Scheduling Criteria:
In each scheduling algorithm has its own set of properties. The algorithms
are selected in a particular situation depending upon its criteria some of the
criteria are:
a) CPU utilization:
Utilization of CPU means keep the CPU busy & executing the users
programs & perform.
b) Throughput: -
It is the number of jobs completed per unit time for long processes this
rate may be less whereas for the short processes it is more.
c) Turnaround time: -
It is the interval from the time of submission of job to its completion.
This is the sum of waiting time, execution time an idle time.
d) Response time: -
The submission of the request until the first response is produced.
Or
The amount of time to be taken to first response.
10
2nd SEM B.Sc.
e) Waiting time: -
The amount of time spent waiting for the allocation of various resources.
It is the difference between turnaround time & actual execution of the
job.
66 ms
Priority scheduling: -
In this algorithm the process may be executes depending the highest priority
of the process. The priority is defined in 2 ways. They are internally & externally.
Internally defined priorities use some measurable quantities to compute the
priority of the process.Externally defined priorities are the concept of importance
of process.The major problem of this scheduling is indefinite starvation or
blocking.
Round Robin [RR] scheduling:
In this scheduling the processes are executed using time slice.
RR technique is mainly designed for time sharing systems. In this technique of
scheduling a small unit of time called a time quantum or time slice is defined.
Each process executed with equal interval of time.
System process
Interactive process
Interactive editing process Five different queue
Batch process
User process
Lowest priority
The ready queue is partitions as commonly a fixed priority preemptive algorithm.
12
2nd SEM B.Sc.
CHAPTER-3
STORAGE MANAGEMENT
Logical address: - To access the data the CPU calculates & generates the memory
address, such memory is Logical address.
Physical address: - The data is stored in memory the actual location where the
data is present is referred to as physical address.
Contiguous allocation memory management
Occupying a set continuous locations to stores the process.
1. Single contiguous allocation,
2. Partitioned allocation,
3. Re – locatable partitioned allocation.
13
2nd SEM B.Sc.
Partitioned allocation: -
In Multiprogrammed environment the multiple jobs are stored in memory.
The easiest method is by dividing the physical memory into several
partitions & allocating each partition to a separate jobs address space.
This size of the partitions can be fixed is called static partition.
The size of the partitions can be depending on the process size is called
Dynamic partition.
Static partition: - This is one of the simplest schemes for memory allocation.
Here the physical memory is divided into a number of partitions of fixed size.
The O.S maintains a tables indicating which parts of the memory are available
& free this table called static partition status table.
14
2nd SEM B.Sc.
Page memory Management: - The jobs address space in divided into pieces
of equal size called pages & physical memory is divided into block of the
same size. Using this mapping facility the pages are placed in the blocks
such that the pages are logically contiguous.
These pages are use certain tables to manage, that table is page map table. The
page map table [PMT] contains a list of memory blocks.
Memory Management function: -
a) Keeping track of track memory status: -
Using page map table.
Memory block table.
b) Allocation policy: - Handled by the job scheduler.
Dynamic address translation: - It is separating the address into 2 parts. Page
number and byte no’s within that page. Replacing the page number by the
memory block number using PMT generates the physical address. In this case
PMT identify the memory block and transformed to high speed associative
memory. So this is much faster.
b+ p
Loc d
15
2nd SEM B.Sc.
Advantage of paged memory allocation: -
a) Eliminates fragmentation, which results in better memory & processor utilization.
b) Compaction overhead eliminated.
Virtual memory Management: -
In this method where only a portion of jobs address space is actually loaded
into physical memory.
Virtual memory Management scheme it uses the memory more than 100%. It
receives the dates continuously depending upon stored address.
Different virtual memory managements are:
a) Demand paging b) Segmentation c) Segmentation & paging.
Demand paging: - The first page is loaded into physical memory other pages of
the job are loaded as and when demanded. Hence it is referred to as demand
paged memory management. The O.S loads this page from the secondary storage
& adjust the page map table entries accordingly.
Segmentation: -Segmentation gives dynamic relocations. Memory wasted due to
fragmentation can be reduced by dividing the address space into logical modules
that may be placed in non – contiguous area of memory. This is called as
segmentation.
Page replacement
When the page is replaced or removed when the job is completed. It is having 3 different tech.
1. First – in first out: -[FIFO]: This algorithm is used to replace the first in
pages or replace the resident page that spent the longest time memory
[oldest page].
2. Least recently used: -[LRU]: This performs better than FIFO. Because it
replaces the least & recently completed pages.
3. Tuple coupling: - The bigger size pages are break into small pages like P1
& P2 then it uses the LRU technique to replace the page.
SWAPPING: -Removing of suspended process from memory to disk [swap – out] &
their subsequent return [swap – in ] is called Swapping.
It improves CPU utilization in PMT if no suitable partition is found it places new
scheduler.
16
2nd SEM B.Sc.
CHAPTER- 4
FILE SYSTEM
File system is consists of collection of files & a directory structure which helps to
organizes the files. This is a sequence of bits, bytes, lines or records this files are
access through files management system.
File Attributes: -
The files are differentiating into different type depending upon the extension
of the file.
Vinay.pas, file.dat, vin.c, file.dat, xx.exe, file.obj,… etc.
And each file is having its own attributes they are: -
NAME: - A file is referred by a symbolic name.
TYPE: - This information is needed for those systems that support different file type.
LOCATION: - This indicates the location of the file.
SIZE: - This indicates the current size of the file. ( In bytes, words or blocks ).
PROTECTION: - Access – control information controls who can do the
operation of reading, writing & execution.
TIME, DATE & USER IDENTIFICATION: - This attributes the creation & lost
modification time & date for the file.
17
2nd SEM B.Sc.
DIRECTORY STRUCTURE: -
The directory can be defined as a symbol table or collection of entries. Each
entry contains the file name and its location in the file system.
18
2nd SEM B.Sc.
Master directory
User directory
Files
The use of tree structured directory minimizes the difficulty in assigning unique
names and this system is very useful to stores the files individual in separate
directory.
File protection: - In a multi – user system, the file protection is very important.
Many different protection mechanisms have been proposed.
Naming: - The user can give the name to the file, so that users cannot easily
guess. But this type of protection can easily be broken down.
Passwords: -Another approach is to be use a password with each file or
access the system in controlled by password.
Access control: - Another approach is making access dependent on the
identity of the user. In this, various users may needs different types of
access to a file.
19
2nd SEM B.Sc.
User program
Logical I/O
4. Indexed allocation: - Here the file allocation table contains a separate one
level index for each file. This index allocation block contains the address of
all the files address.
20
2nd SEM B.Sc.
1. PRIORITY
This is based on priority. The control of scheduled is outside the control of
disk management software.
Usually starter jobs are given higher priority than longer jobs. The longer jobs
have to wait excessively for longer times.
1. LAST IN FIRST OUT: This algorithm is used place of scheduling the jobs a
disk the order of recently placed files. However if the kept busy because of
larger workload. In lasts in first out policies its work on the basis of stack.
3. SCAN:
In scan scheduling the arm is required to move in one direction only
Satisfying all out standing requests enroll, until it reaches the last track in that
direction.
This scan moves the head in only one direction; these are many different type of
C = SCAN
N = SCAN
F = SCAN
21
Deadlock Characterization
Deadlock can arise if four conditions hold simultaneously. (All four must hold)
o Mutual exclusion: only one process at a time can use a resource.
o Hold and wait: a process holding at least one resource is waiting to acquire
additional resources held by other processes.
o No preemption: a resource can be released only voluntarily by the process holding it,
after that process has completed its task.
o Circular wait: there exists 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.
Resource Allocation Graph
o A set of vertices V and a set of edges E.
o V is partitioned into two types:
P = {P1, P2, ..., Pn} , the set consisting of all the processes in the system.
R = {R1, R2, ..., Rm}, the set consisting of all resource types in the system.
o request edge – directed edge Pi --> Rj
o assignment edge – directed edge Rj --> Pi
o Example Resource Allocation graph with no cycles:
o Example Resource Allocation Graph with cycles :
o Basic Facts:
If graph contains no cycles => no deadlock.
If graph contains a cycle =>
if there is only one instance per resource type, then deadlock.
if there are several instances per resource type, then we have the
possibility of deadlock.
Methods for Handling Deadlocks
Safe State:
Basic Facts:
o If a system is in safe state => no deadlocks.
o If a system is in unsafe state => possibility of deadlock.
o Avoidance =>ensure that a system will never enter an unsafe state.
Bankers Algorithm
o Multiple instances.
o Each process must a priori claim maximum use.
o When a process requests a resource it may have to wait.
o When a process gets all its resources it must return them in a finite amount of time.
o Data Structures for the Banker’s Algorithm:
Let n = number of processes, and m = number of resource types.
Available : Vector of length m. If Available[j]= k, there are k instances of
resource type Rj available.
Max : n x m matrix. If Max[i,j]= k, then process Pi may request at most k
instances of resource type Rj.
Allocation : n x m matrix. If Allocation[i,j]= k, then Pi is currently allocated k
instances of Rj.
Need : n x m matrix. If Need i,j]= k, then Pi may need k more ainstances of Rj
to complete its task.
o Notation:
Given X and Y are vectors of length n, we say that X<=Y (less than or equal) if
and only if X[i] <= Y[i] for all i=1,2,..., n.
For example, if X = (1, 7, 3, 2) and Y = (0, 3, 2, 1), then Y <= X. Y < X if Y
<= X and Y <> X
We treat each row in the matrices Allocation and Need as vectors and refer to
them as Allocationi and Needi, respectively. Therefore, the vector Allocationi
specifies the resources currently allocated to process Pi; the vector Needi
specifies the additional resources that process Pi may still request to complete
its task.
o Safety Algorithm:
Step1: Let Work and Finish be vectors of length m and n, respectively.
Initialize:
Work := Available
Finish[i] := false for i = 1, 2, ..., n.
Step2: Find an i such that both: (a unfinished process Pi whose future need for
resources can be accommodated)
Step3:
Work := Work + Allocationi
Finish[i] := true
go to step 2.
Step4: If Finish[i] = true for all i, then the system is in a safe state. print the
safe sequence out
else declare state unsafe
o Resource-Request Algorithm for process Pi
Requesti = request vector for process Pi . If Requesti[j]= k, then process Pi wants k
instances of resource type Rj .
Step1: If Requesti <= Needi, go to step 2. Otherwise, raise error condition,
since process has exceeded its maximum claim.
Step2: If Requesti <= Available, go to step 3. Otherwise, Pi must wait, since
resources are not available.
Step3: Pretend to allocate requested resources to Pi by modifying the state as
follows:
Available:= Available - Requesti;
Allocationi := Allocationi + Requesti;
Needi := Needi - Requesti;
If safe --> the resources are allocated to Pi.
If unsafe --> Pi must wait, and the old resource-allocation state is
restored.