Pages

2 Jun 2012

Cs604 3rd assignment solution spring 2012


Question 1:
There are six processes given below with their run time units. Assume that all processes arrive in numerical order at time 0 then answer the questions given below:
Process ID CPU Requirements
P                        1    5
P                        2   4
P                       3    7
P                       4    1
P                      5     8
P                      6    10
Show the scheduling order for these processes under first-come-first-served, shortest-job first, and round-robin scheduling (quantum = 4).
Solution:
 FCFS = p1,p2,p3,p4,p5,p6

SJF = p4,p2,p1,p3,p5,p6

round  robin = p1,p2,p3,p4,p5,p6,p1,p3,p5,p6,p6
Question 2:
There are two processes that could take place even at the same time. One process helps in getting amount from the ATM and the second helps in depositing the money in the bank account through a cheque. You ensure mutual exclusiveness by using semaphore with wait and signal operations. Write pseudo-code or algorithm for these two processes.
Code for   Depositing Money process.
do
{
…………….
Deposit money in nextp
…………..
Wait (getting);
Wait(mutex);
………….
Deposit nextp to ATM
………
Signal(mutex);
Signal(deposit);
}
While(1);
Code for getting money process
do
{
Wait (deposit);
Wait(mutex);
………….
get money from ATM to nextc
………
Signal(mutex);
Signal(getting);
Get the money in nextc
………….
}
While(1);

0 comments:

Post a Comment