Professional Documents
Culture Documents
Operating Systems Assignment PDF
Operating Systems Assignment PDF
- Sai Sushmitha.P
(1602-12-737-100)
I.T. - ¾ ( section – B)
SECTION-A
A set of processes is deadlocked when every process is the set is waiting for a resource that
is currently allocated to another process in the set ( which can only be released when that
other waiting process makes progress ).
Semaphores require busy waiting. While a process is in its critical section, any other process
that tries to enter its critical section must loop continuously in the entry code. This
continual looping is clearly a problem in real multi programming system where a single CPU
is shared among many processes. Busy waiting wastes CPU cycles that other processes
might use productively. This type of semaphore is called Spinlock because the process
“spins” while waiting for the lock.
Interrupts cause the operating system to change a CPU from its current task and to run
a kernel routine. When an interrupt occurs, the system needs to save the current
context of the process currently running on the CPU so that it can restore that context
when its processing is done, essentially suspending the process and then resuming it.
Switching the CPU to another process requires performing a state save of the current
process and a state restore of a different process. This task is known as context
switching.
SECTION-B
Safe State
When a process requests an available resource, system must decide if immediate
allocation leaves the system in a safe state.
System is in safe state if there exists a safe sequence of all processes.
Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi can still request can
be satisfied by currently available resources + resources held by all the Pj, with j<I.
1. If Pi resource needs are not immediately available, then Pi can wait until all Pj have
finished.
2. When Pj is finished, Pi can obtain needed resources, execute, return allocated
resources, and terminate.
3. When Pi terminates, Pi+1 can obtain its needed resources, and so on.
Baker’s algorithm
- Multiple instances.
- Each process must a priori claim maximum use.
- When a process requests a resource it may have to wait.
- When a process gets all its resources it must return them in a finite amount of
time.
It is also called job scheduler. Long term scheduler determines which programs are
admitted to the system for processing. Job scheduler selects processes from the queue
and loads them into memory for execution. Process loads into the memory for CPU
scheduling. The primary objective of the job scheduler is to provide a balanced mix of
jobs, such as I/O bound and processor bound. It also controls the degree of
multiprogramming. If the degree of multiprogramming is stable, then the average rate
of process creation must be equal to the average departure rate of processes leaving
the system. On some systems, the long term scheduler may not be available or minimal.
Time-sharing operating systems have no long term scheduler. When process changes
the state from new to ready, then there is use of long term scheduler.
Short term scheduler also known as dispatcher, execute most frequently and makes the
fine grained decision of which process to execute next. Short term scheduler is faster
than long term scheduler.
Medium term scheduling is part of the swapping. It removes the processes from the
memory. It reduces the degree of multiprogramming. The medium term scheduler is in-
charge of handling the swapped out-processes.
S.N. Long Term Scheduler Short Term Scheduler Medium Term Scheduler
It is a process swapping
1 It is a job scheduler It is a CPU scheduler
scheduler.
Speed is lesser than short term Speed is fastest among Speed is in between both short
2
scheduler other two and long term scheduler.
a)
FCFs:
P1 P2 P3 P4 P5
0 10 11 13 14 19
SJF:
P2 P4 P3 P5 P1
0 1 2 4 9 19
Time = (1+2+4+9+19)/5=7 S
Priority:
P2 P5 P1 P3 P4
0 1 6 16 18 19
Time = (0+1+6+16+18+19)/5=12 s
round robin:
P P P P P P P P P P P P P P P P P P P
1 2 3 4 5 1 3 5 1 5 1 5 1 5 1 1 1 1 1
b) SJF
Impossible to implement
Processer should know in advance how much time process will take.
Each process is represented in the operating system by a process control block (PCB)
also called a task control block. PCB is the data structure used by the operating system.
Operating system groups all information that needs about particular process. Process
control block includes CPU scheduling, I/O resource management, file management
information etc.. The PCB serves as the repository for any information which can vary
from process to process. Loader/linker sets flags and registers when a process is
created. If that process get suspended, the contents of the registers are saved on a stack
and the pointer to the particular stack frame is stored in the PCB.
Pointer
Pointer points to another process control block. Pointer is used for maintaining the
scheduling list.
Process State
Process state may be new, ready, running, waiting and so on.
Program Counter
Program Counter indicates the address of the next instruction to be executed for this
process.
CPU registers
CPU registers include general purpose register, stack pointers, index registers and
accumulators etc. number of register and type of register totally depends upon the
computer architecture.