Operating System ANSWERS
Operating System ANSWERS
Booting:-Booting is basically the process of starting the computer. When the CPU is first switched ON it
has nothing inside the memory. So, to start the computer, we load the operating system into the main
memory. Therefore, loading the OS to the main memory to start the computer is booting. Hence, the Os
helps to start the computer when the power is switched ON.
Managing the input/output devices:- The OS helps to operate the different input/output devices. The
OS decides which program or process can use which device. Moreover, it decides the time for usage. In
addition to this, it controls the allocation and deallocation of devices.
Multitasking:-The OS helps to run more than one application at a time on the computer. It plays an
important role while multitasking. Since it manages memory and other devices during multitasking.
Therefore, it provides smooth multitasking on the system.
Platform for other application software:-Users require different application programs to perform
specific tasks on the system. The OS manages and controls these applications so that they can work
efficiently. In other words, it acts as an interface between the user and the applications.
Q10. What are the steps to be followed for process management when an interrupt comes to a
running process?
Ans-
If any interrupt occurs, it is indicated by an interrupt flag. The CPU will go to interrupt handler
routine. Interrupt handler then checks the type of interrupt and executes the appropriate
function. It involves overhead but is still better than the CPU waiting for I/O completion
or other activities. Interrupt handler activates most prior able activity first and later
deferrable part will be handled.
interrupt processing
Step 1 − First device issues interrupt to CPU.
Step 2 − Then, the CPU finishes execution of current instruction.
Step 3 − CPU tests for pending interrupt requests. If there is one, it sends an acknowledgment
to the device which removes its interrupt signal.
Step 4 − CPU saves program status word onto control stack.
Step 5 − CPU loads the location of the interrupt handler into the PC register.
Step 6 − Save the contents of all registers from the control stack into memory.
Step 7 − Find out the cause of interrupt, or interrupt type, or invoke appropriate routine.
Step 8 − Restore saved registers from the stack
Step 9 − Restore PC to dispatch the original process.
Q11. Consider the following set of processes with the length of CPU burst time given in the
mili seconds.Draw the Gantt chart and calculate Average Turnaround Time , Average
Waiting Time for FCFS and RR(Q= 2)Scheduling Algorithm.
Q22. What is semaphore? How can you solve Producer- Consumer Problem using
semaphore?
Semaphore was proposed by Dijkstra in 1965 which is a very significant
technique to manage concurrent processes by using a simple integer value,
which is known as a semaphore. Semaphore is simply an integer variable
that is shared between threads. This variable is used to solve the critical
section problem and to achieve process synchronization in the
multiprocessing environment.
In an Unsafe state, the operating system cannot prevent processes from requesting resources in
such a way that any deadlock occurs. It is not necessary that all unsafe states are deadlocks; an
unsafe state may lead to a deadlock.
Q28. Consider a system with 5 processes and 3 resources types A, B, C. Resource type A has
7 instances, resource type B has 3 instances and resources type C has 6 instances
Allocation Max
ABC ABC
P0 001 111
P1 200 323
P2 132 431
P3 101 001
P4 001 321
Calculate Available matrix, need of matrix using the Banker’s algorithm, Is the system in a
safe state? If yes, what is the safe sequence?
Q29. Explain the must satisfied conditions to dead locked system.
Q30. Describe User level threads and Kernel level threads with its advantages and
disadvantages.
Q31. Explain the different schedulers with suitable queuing diagram.
Q32. Give the comparison between paging and segmentation.
Q37. What is dynamic storage allocation problem? How will you provide the solution for this.
ANS-
Dynamic memory allocation is when an executing program requests that the operating system
give it a block of main memory. The program then uses this memory for some purpose.
Usually the purpose is to add a node to a data structure. In object oriented languages, dynamic
memory allocation is used to get the memory for a new object. Solution for Dynamic memory
allocation problem
First Fit
In the first fit approach is to allocate the first free partition or hole large enough which can
accommodate the process. It finishes after finding the first suitable free partition.
Best Fit
The best fit deals with allocating the smallest free partition which meets the requirement of
the requesting process. This algorithm first searches the entire list of free partitions and
considers the smallest hole that is adequate. It then tries to find a hole which is close to actual
process size needed.
Worst fit
In worst fit approach is to locate largest available free portion so that the portion left will be
big enough to be useful. It is the reverse of best fit
7,0,1,2,0,3,0,4,2,3 0,3,2,1,2,0,1,7,0,1
Q46. Consider a disk queue with I/O request on the following cylinders in their arriving
order:
6,10,12,54,97,73,128,15,44,110,34,45
The disk head is assumed to be at cylinder 23 and moving in the direction of decreasing number
of cylinders. The disk consists of total 150 cylinders.
The disk head is assumed to be at cylinder 23 and moving in the direction of decreasing numberof
cylinders. The disk consists of total 150 cylinders.
a) Draw track chart for FCFS, SSTF, SCAN, C-SCAN algorithms of disk
scheduling.
Q49. What are the reasons to provide I/O buffering? mention its types.
Q50. Write notes on
a) Copy-on-write
Copy on Write or simply COW is a resource management technique. One of its main use is in the
implementation of the fork system call in which it shares the virtual memory(pages) of the OS.
In UNIX like OS, fork() system call creates a duplicate process of the parent process which is called as
the child process.
The idea behind a copy-on-write is that when a parent process creates a child process then both of these
processes initially will share the same pages in memory and these shared pages will be marked as copy-
on-write which means that if any of these processes will try to modify the shared pages then only a copy
of these pages will be created and the modifications will be done on the copy of pages by that process
and thus not affecting the other process.
• Available –
A vector of length m indicates the number of available resources of
each type.
• Allocation –
An n*m matrix defines the number of resources of each type currently
allocated to a process. Column represents resource and rows
represent process.
• Request –
An n*m matrix indicates the current request of each process. If
request[i][j] equals k then process Pi is requesting k more instances
of resource type Rj.