Professional Documents
Culture Documents
Cmpe242 Fall 2009-2010 MT1
Cmpe242 Fall 2009-2010 MT1
MIDTERM I
a) Operating System controls and coordinates use of hardware among various applications
and users.
b) In simple batch systems, Spooling which refers to transferring input onto a temporary
working area to be later accessed by another program is used to improve performance.
c) In Symetric Multiprocessing each processor runs and identical copy of the operating
system which communicates with each other as needed.
d) In computer systems generally we have two communication models. With these models
communication may take place using either shared memory or message passing .
a) The main advantage of distributed systems is that they allow shared memory model type
communication between processes. …F.
b) The next process to get CPU is selected using synchronization algorithm. ……F….
c) Two processes can not be in their running states at a given time. ……T..
d) Device controller informs CPU that it has finished its operation by causing an interrupt.
……T….
Shared data
bool lock[2] = { false, false }; // In shared memory
int turn = 0; // In shared memory
1. Mutual exclusion is satisfied. While one process running in its CS other process should
wait in while (lock[other] ); loop.
2. Progress is satisfied. While one process running in its remainder section other process can
continue and go in its CS because of the lines:
while ( turn != i )
{
while ( lock[other] );
turn = i;
}
3. Bounded waiting is not satisfied because while one process waiting in while (lock[other] );
loop other process can go into its CS more than once
Q.3. [25 pts] Given the following table, how will these processes be scheduled using FCFS,
SJF and SRTF algorithms? Create a Gantt chart showing when each process will be
scheduled, and calculate the waiting times and turnaround times for the processes for each
scheduling algorithm.
P0 P1 P2 P3 P4
0 6 8 15 16 19
P0 P1 P3 P4 P2
0 6 8 9 12 19
P0 P1 P0 P3 P4 P2
0 3 5 8 9 12 19
Draw the Gantt charts for the CPU and I/O device to compute the waiting time and
turnaround time (tat) of all processes and CPU utilization. Put your answers into the table
given below.
A C A B C A B
0 5 6 8 13 16 22 24 25
C A B
0 6 16 22 24
Shared data:
wait(s1); wait(s2);
signal(s1); signal(s2);
} } }
a) The execution can be in the order: first produceA, then produceB, then produceC.
……T…. (T/F)
b) A race condition may occur between process A and process C. ……F…. (T/F)
c) If the semaphore variables are initialized as s1=0 and s2=1, produceC, then produceB,
then produceA will be a possible sequence. ……F…. (T/F)
d) If the semaphore variables are initialized as s1=0 and s2=1, produceC, then produceA,
then produceB will be a possible sequence. ……T…. (T/F)
e) If the semaphore variables are initialized as s1=0 and s2=1, a race condition may occur
between process A and process C. ……T…. (T/F)
ANSWER THE PARTS THAT YOU ARE SURE. YOU WILL GET NEGATIVE GRADES FROM
WRONG PARTS