Operating system communicate between user and
Operating system hardware.
Important feature of Os is
It's like government program execution
User
Applications
↓
Os
↓ ↓
Hard ware
1) Uni programming Os : an Os which allows only one process in main
Memory at time.
2) multiprogramming os : an os which allows multiple programs tobe in
main memory.
Types of multiprogramming
Non preemptive if a
process runs on CPU Preemptive if a
then it leaves CPU running process out of
only when it wants os the CPU forforcefully
forcefully can not
take out the process
from CPU
Multitasking os extension of preemptive multiprogramming os in which
process are executed in round robin manner
Multiuser os it is used ou computer system which can be used by
multiple user simultaneously
user user2 user3
Multiuser OS
Computer system
& <PU , HDD , RAM)
Multiprocessing os it is used on computers with multiple CPU's
Types
Tightly coupled Loosely coupled
shared - memory (distributed system)
Main Memory
< Bj CDU CDu
Cy
ummue mea
Real time Os it works on real time data and events
each process has deadline it has two types hard
time Os and soft time Os
Embedded os os used on embedded systems which are attached with
other devices like cars, AC
Hand-held is as used on hand held devices like mobile phones etc....
System call A system call is a way for programs to interact with Os
Dual mode of operations
2 modes
user mode (mode bit = 1)
kernel / system / supervisor / privileged mode ( mode bit =o ).
User process executing call system call return system call
Kernel
Mode bit=0 Return mode bit=1
Execute system call
It is used for system protection
Parts of os
1. GUI (graphical
user interface.
Shell 2. Command line
interface
Core part of os
Kernel
which has all os
features
Process program in execution is called a process
&
Process = program + runtime activity
Process as data
structure
Representation / Operations Attributes
Definition
(Set of instructions ) implementation.
Each memory is stored in memory in 4 sections
Rum
Os Stack = Activation record
Process I
Dynamic memory
Heap - allocation
Process 2
Data section -
Global static variable
Process 3
Code (text
section) = Program instructions
Topic: - Process state (preemptive states )
New
Terminated
Preemption
Admitted Exit
Ready Running
T
I/O Or event Scheduler dispatch. Waiting for
completion
I/O or event
Waiting /
blocked
2 transition are voluntary:- 1) running to terminated
2) running to blocked (process can take this two
transition by own)
Process scheduling : it is use for efficiency
Context switch:- 1. Context (CPU register values) of running
process's is stored in its PCB.
2. Context of next process is loaded into CPU register from PCB,
# While running process can access its PCB from main memory ?
Answer:- NO
There are three types of 1. Long term scheduler brings a
scheduler process from new state to ready
1. Long term scheduler state
2. Small term scheduler 2. Short term scheduler Selects
3. Mid term scheduler one of the ready process to run
on CPU
3. Mid term scheduler it perform
swapping of [Link] is done
on the basis of priority of
process.
Function - make a selection of a process to
CPU scheduling run next on CPU among all ready process
Goal - 1) minimise wait time and turn-
around time
2) maximize CPU utilization (throughput)
3) fairness
( FCFS ) First come first serve
Do practice question for above scheduling process
Convoy Effect - if a-big process schedule first then it delays
other process’s execution significantly , hence performance will
slow down
( Smallest Job first ) SJF
Practice the above process scheduling type
SRTF (shortest remaining time first)
LJF (longest job first )
LRTF ( longest remaining time first )
HRRN ( highest response ratio next)
Priority based algorithm
Round Robin
Fork system call is used for creating a
Process synchronisation new process, which is called child
. process.
Types of process
[Link]:- the process which do not communicate with other
process
2. Cooperating / coordinating / communicating :- the process
Which communicate with other process.
Problems without synchronization:
1) inconsistency 2) loss of data 3) deadlock
Critical section
The critical section is a code segment where
the shared variables can be accessed
Race condition
Race condition is an undesirable situation ' it occurs when the final
result of concurrent process depends on the sequence in which the
processes complete their execution.
int x= 5
Proces a
=
RI =
RI + 2 R2 = R2 + 3
x= RI x = R2
The answer will change by the sequence of solving order
1
Solution of critical section
r
problem
Requirements of critical section problem solution
1. Mutual exclusion
2. Progress
3. Bounded waiting
Mutual exclusion
If one process is executing the critical section, then other process is
not allowed to enter into critical section.
Progress
If no any process is in critical section and any process wants to enter
into critical section , then the process must be allowed.
Bounded waiting
If a process's P1 is executing in critical section and other process P2
is waiting for critical section, then the waiting time of P2 must be
bounded. Which means p 1 must not enter into the critical section
again and again by keeping p2 in waiting for long.
it's like a switch
checking the possibilities of the
&
both satisfying all three conditions
or not
important
KEEP
CALM
DRINK
# Deadlock
SODA
If two or more process are waiting for such au event
which is never going to occur '
# resource allocation graph
It denotes which process is using which resource and is waiting for
which process.
-
Nodes /vertices process
resources
R3 Ru
-
-
-
Pl
Pe P3
a
I R2
RI
Pu
# necessary conditions for deadlock
1. Mutual exclusion
2. Hold & wait
3. No -preemption
4. Circular wait
1. Mutual exclusion - At a time one resource is used by only one
process.
2. Hold & wait - each deadlock process must hold atleast one
resource and should wait for atleast one resource.
3. No- preemption - A resource which is allocated to a process can
not be preempted.
4. Circular wait- each deadlock process must wait for each other in
circular manner.
# Deadlock prevention
Try to represent at least one of neccescerry conditions for
deadlock.
[Link] Algorithm
The bankers algorithm is a resource allocation and
Deadlock avoidance algorithm that tests for safety
Deadlock detection
1. When all resources have single instances = using wait for graph
2. When resources have multiple instances
Multiple instances
KEEP
CALM
DRINK
Memory management
SODA
Functions Of memory management
1. Memory allocation
Goals of memory management.
1. Maximum utilization of space minimum wastage of space
( fragmentation)
2. Ability to run larger programs with limited space
Partition allocation policy
1. First fit - The first fit partition from starting which can store
the process is allocated.
2. Best fit - The smallest partition which can be used to store the
process is allocated
3. Worst fit - the biggest partition is allocated -
4. Next fit - The first partition from previously allocated
partition..
5.
.
Paging
Process is dividend inequal size of pages
Physical memory is dividend in same equal size of frames.
Pages are scattered in frames.