Professional Documents
Culture Documents
Assignment No1
Assignment No1
Assignment No1
Assignment no 1(solution)
1) Differentiate between monolithic and microkernel.
BASIS FOR
MICROKERNEL MONOLITHIC KERNEL
COMPARISON
Basic In microkernel user services and kernel, In monolithic kernel, both user services and kernel
services are kept in separate address space. services are kept in the same address space.
Size Microkernel are smaller in size. Monolithic kernel is larger than microkernel.
Extendible The microkernel is easily extendible. The monolithic kernel is hard to extend.
Security If a service crashes, it does effect on If a service crashes, the whole system crashes in
Code To write a microkernel, more code is To write a monolithic kernel, less code is required.
required.
Example QNX, Symbian, L4Linux, Singularity, K42, Linux, BSDs (FreeBSD, OpenBSD, NetBSD),
Mac OS X, Integrity, PikeOS, HURD, Microsoft Windows (95,98,Me), Solaris, OS-9, AIX,
5)
| P1 | P2 | P3 | P1 | P2 | P1 | P2 | P1 | P1 | P1 | P1 |
|----|----|----|----|----|----|----|----|----|----|----|
| 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
| P1 | P2 | P3 | P1 |
|----|----|----|----|
| 0 | 10 | 15 | 17 | 19 |
Average Waiting Time = (0 + 9 + 13) / 3 = 22 / 3 ≈ 7.33
Average Turnaround Time = (10 + 14 + 15) / 3 = 39 / 3 ≈ 13
SJF
| P3 | P2 | P1 |
|----|----|----|
| 0 | 2 | 6 | 11 | 19 |
Average Waiting Time = (0 + 3 + 9) / 3 = 12 / 3 = 4
Average Turnaround Time = (2 + 8 + 19) / 3 = 29 / 3 ≈ 9.67
User threads are supported above the kernel level and are implemented by a thread library at a user level
.The library provides support from the kernel because the kernel is unaware of the user level
threads as well as all thread creation and scheduling are done in user space without the need of kernel
intervation. This threads are fast to create and manage.
2.) Kernel Threads – Kernel threads are directly supported by the os .the kernel performs thread creation and
manages in kernel space because thread management is done by the os , kernel threads are generally
slower to create and manage than user thread.
11) What is the critical section problem? Mention three conditions that must be satisfied
by its solution?
The critical section is a code segment where the shared variables can be accessed. An atomic
action is required in a critical section i.e. only one process can execute in its critical section at a time.
All the other processes have to wait to execute in their critical sections.
Mutual Exclusion: Our solution must provide mutual exclusion. By Mutual Exclusion, we mean that if
one process is executing inside critical section then the other process must not enter in the critical section.
Progress : Progress means that if one process doesn't need to execute into critical section then it should not
stop other processes to get into the critical section
Bounded Waiting : We should be able to predict the waiting time for every process to get into the critical
section. The process must not be endlessly waiting for getting into the critical section.
Architectural Neutrality : Our mechanism must be architectural natural. It means that if our solution is
working fine on one architecture then it should also run on the other ones as well.
12) What is a Deadlock? Explain the necessary conditions for a deadlock to take place.
A Deadlock is a situation that involves the interaction of more than one resource and process with
each other. Deadlock can occur if four conditions are present simultaneously:
Mutual Exclusion: At least one resource must be held in a non-sharable mode, meaning it cannot be
simultaneously used by multiple processes.
Hold and Wait: A process must be holding at least one resource while waiting for another resource to be
released by another process.
No Preemption: Resources cannot be forcibly taken away from a process. They must be released voluntarily.
Circular Wait: A circular chain of two or more processes exists, where each process is waiting for a resource
held by another process in the chain.
13) What is deadlock avoidance? Explain the algorithm with an example.
Ans - Deadlock avoidance is another technique used in operating systems to deal with deadlocks. Unlike
deadlock prevention, which aims to eliminate the possibility of deadlocks, deadlock avoidance focuses on
dynamically detecting and avoiding situations that could lead to deadlocks.Bankers algorithm is used to solve
deadlock avoidance. Example :-
Suppose we have 3 processes(A, B, C) and 3 resource types(R1, R2, R3) each having 5 instances.