Q 1. Consider the following situations in a typical Multi Programmed Computer system: • The O.S. of the given Computer System employs pre emptive FIRST COME FIRST SERVED Scheduling. • It employs semaphores to achieve Mutual Exclusion of the single printer it possesses. Any process wishing to use the printer , must do so in the KERNEL mode. All processes in the KERNEL mode, possesses the Highest Priority. • The Printer is currently printing the Output generated by the process PA. The process PA has got some more tasks to complete even after printing is done. • Another process PB has been waiting for sometime for the printer. • The CPU is currently executing the process PC. • Two other processes PD & PE are ready to be executed. The Process PE having arrived earlier. Q.1.(a) i. Identify the states of each of the processes PA, PB, PC, PD & PE along with proper justifications.  Ans. 1 (a). Sl. Current State Remarks / Justification No. Process 1 PA Blocked Carrying out printing i.e. I/O Activity 2 PB Waiting in Blocked Had asked for I/O Activity waiting for State Printer to be Free 3 PC Running Currently being Executed 4 PD In READY Queue Ready to be Executed behind PE 5 PE In READY Queue in Ready to be Executed front of PD Marking Policy : 1 Mark for Identifying Processes in Ready State. 1.5 Marks for Identifying Processes in Blocked State. 0.5 Mark for Identifying Process in Running State. Contd. 2 - 2- Q. 1(a) ii. When the printer finishes printing the job associated with the process PA, depict the sequence of events that take place in a stepwise fashion. What will be the new states of each of the processes PA, PB, PC, PD & PE ? [4+2=6] Ans. 1 (b) Sequence of Events that take place after printing is over 1) The Printer interrupts the CPU. 2) The CPU on completion of the current instruction of the presently running process PC switches mode to KERNEL mode service the printer interrupt. 3) The printer interrupt service routine brings the blocked process PA , as well as the Waiting process PB , both of which happens to be in KERNEL mode, to READY state. PC switches mode back to USER mode & resumes normal operation. 4) Subsequently the Process PA , is scheduled by the Scheduler on the top priority basis (it being in the Kernel Mode ) i.e. the Process PA is brought into the running state by pre-empting process PC. 5) While in RUNNING state the process PA does the following : a) It releases the printer by executing some System Code [SIGNAL] so that the process PB can use it. b) Next it comes back to the user Mode and normally is pre-empted . 6) Next the scheduler schedules afresh and when the process PB is scheduled i.e. it comes the running state, then it may issue the printer request again and assuming all processes has the same priority , the process PB gets to use the printer , while using the printer , PB remains blocked and a new process is selected by the scheduler to run next which should be PE. Marking Policy : 2 Marks for Points 1), 2) & 3) 1 Mark for Point 4) , 1 Mark for the Rest. Sl. New State Remarks / Justification No. Process 1 PA In READY Queue at the Finished I/O, Some more Task may End be Left 2 PB Blocked Carrying out printing i.e. I/O Activity 3 PC In READY Queue at the Ready to be Executed End 4 PD In READY Queue at front Ready to be Executed of PA 5 PE Running Currently being Executed Marking Policy : 1 Mark for Identifying Processes in Ready State. 0.5 Marks for Identifying Processes in Blocked State. 0.5 Mark for Identifying Process in Running State.
Pages to are hidden for
"Semaphore_Process"Please download to view full document