Practice Test 2 with Answers - Operating Systems and Networking | CS 330, Exams of Operating Systems

Material Type: Exam; Professor: Sengupta; Class: Operating Systems & Networking; Subject: Computer Information Science; University: SUNY Institute of Technology at Utica-Rome; Term: Spring 2007;

Typology: Exams

Pre 2010

Uploaded on 08/09/2009

koofers-user-bni
koofers-user-bni 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Test 2
Operating Systems and Networking
CS330
Spring 2007
Answer only five from the following
Allotted time: 1 hr and 50 minutes
Date: March 14, 2007
Policy: Open notes, text and reference books.
1. CPU periodically receives data from devices like keyboard, mouse, network interface card, etc. To
figure out if there’s any data from a device for CPU, it must employ some method like polling or
interrupt from the device to CPU. Briefly discuss when one is more efficient than the other.
Polling is CPU intensive, but simple. If CPU has nothing else to do, it may not be a major
problem. In a multitasking, it’s expensive to devote precious CPU time on polling pursuits. In
interrupt driven I/O, one needs extra hardware. The situation becomes complicated when the
system is connected to multiple interrupt lines to receive interrupt from multiple devices. In such
events polling would be desirable. If we know in advance polling would not cause too much of
CPU time drainage, polling would be preferred. If we know a priori that the likelihood of an
interrupt from a device is low, interrupt would be the chosen scheme.
2. For a system of interest, assume the context switching time in a RR system is negligible. Each
process when it arrives at CPU gets
units of time-slice. Will I/O utilization increase or
decrease if
is increased? State your rationale.
On a pure CPU-bound or IO-bound jobs, I/O utilization will not change. However, on a mixed
stream I/O utilization will decrease. Since I/O bound processors, on arrival in CPU, request for I/O
processing density of such requests will decline with the increasing size of
. In this mode, the
CPU-bound jobs tend to hang around the CPU longer delaying the eventual arrival time of I/O
bound processes at CPU. Accordingly, I/O processors would be forced to wait resulting in a
decrease of I/O device utilization.
3. Consider the same system as outlined in the previous question. If
is reduced, will the reduction
cause some programs to take longer times to finish? Why, or why not?
For some programs, it will take longer. Suppose there are programs requiring exactly 1 time-slice.
If
is reduced, they will take 2 or more time-slices to complete. Also, it would allow some
programs to finish earlier if they needed less than one CPU time slice currently being used.
4. In the lecture, it was pointed out that a busy-waiting by a process to get into its critical section
should generally be avoided, if possible. Indicate why. Could there be any situation, however,
where busy-waiting might not be all that bad? Indicate how.
If busy-waiting is likely to involve wasting only a small fragment of CPU time on the average,
then it is definitely worth it. Alternatives to busy-waiting via semaphore or monitor module entail
a great deal of overhead cost.
5. The two processes shown below access a shared printer to do their print tasks via a semaphore S
which is initialized to 0. It is conjectured that the following output strings are either individually
valid or invalid when the two processes are run concurrently. Mark the output strings either as
valid or invalid strings.
pf3
pf4

Partial preview of the text

Download Practice Test 2 with Answers - Operating Systems and Networking | CS 330 and more Exams Operating Systems in PDF only on Docsity!

Test 2

Operating Systems and Networking

CS

Spring 2007

Answer only five from the following Allotted time: 1 hr and 50 minutes Date: March 14, 2007 Policy: Open notes, text and reference books.

  1. CPU periodically receives data from devices like keyboard, mouse, network interface card, etc. To figure out if there’s any data from a device for CPU, it must employ some method like polling or interrupt from the device to CPU. Briefly discuss when one is more efficient than the other. Polling is CPU intensive, but simple. If CPU has nothing else to do, it may not be a major problem. In a multitasking, it’s expensive to devote precious CPU time on polling pursuits. In interrupt driven I/O, one needs extra hardware. The situation becomes complicated when the system is connected to multiple interrupt lines to receive interrupt from multiple devices. In such events polling would be desirable. If we know in advance polling would not cause too much of CPU time drainage, polling would be preferred. If we know a priori that the likelihood of an interrupt from a device is low, interrupt would be the chosen scheme.
  2. For a system of interest, assume the context switching time in a RR system is negligible. Each

process when it arrives at CPU gets  units of time-slice. Will I/O utilization increase or

decrease if  is increased? State your rationale.

On a pure CPU-bound or IO-bound jobs, I/O utilization will not change. However, on a mixed stream I/O utilization will decrease. Since I/O bound processors, on arrival in CPU, request for I/O

processing density of such requests will decline with the increasing size of . In this mode, the

CPU-bound jobs tend to hang around the CPU longer delaying the eventual arrival time of I/O bound processes at CPU. Accordingly, I/O processors would be forced to wait resulting in a decrease of I/O device utilization.

3. Consider the same system as outlined in the previous question. If  is reduced, will the reduction

cause some programs to take longer times to finish? Why, or why not? For some programs, it will take longer. Suppose there are programs requiring exactly 1 time-slice.

If  is reduced, they will take 2 or more time-slices to complete. Also, it would allow some

programs to finish earlier if they needed less than one CPU time slice currently being used.

  1. In the lecture, it was pointed out that a busy-waiting by a process to get into its critical section should generally be avoided, if possible. Indicate why. Could there be any situation, however, where busy-waiting might not be all that bad? Indicate how. If busy-waiting is likely to involve wasting only a small fragment of CPU time on the average, then it is definitely worth it. Alternatives to busy-waiting via semaphore or monitor module entail a great deal of overhead cost.
  2. The two processes shown below access a shared printer to do their print tasks via a semaphore S which is initialized to 0. It is conjectured that the following output strings are either individually valid or invalid when the two processes are run concurrently. Mark the output strings either as valid or invalid strings.

Process P: Process Q: { …. { …. while (TRUE) while (TRUE) { { wait(S); signal(S); print(P); print(Q); } } } // end_P } // end_Q Possible output claims are: A) QPQPQPQP B) QQQPPQPP C) PQPQPQPQ D) QPPPQPQQ Only D is invalid.

  1. Consider the following situation. Peter, Paul and Mary are all distinguished members of Caribbean Pirates Unconventional. Three of them share a treasure chest which contains valuable trinkets and gold coins. Periodically, though, Peter and Paul steals from the chest (naturally without anybody’s knowledge) to purchase rum and cigars when they run out of money without alerting anyone in the group. Mary has an inkling of what’s going on, but she has decided not to open her mouth and create even a bigger problem. Every time she has some valuable to store into the chest she does so without letting any of her partners know. The CPU is a technologically advanced organization. Consequently, their treasure chest is accessed only through a monitor. The three threads depicting our three heroes are indicated below: condition t; // trinket condition lock on chest; Peter and Paul: Get lock on chest; trinket = monitorCPU.delete(chest); Release lock; Mary: Get lock on chest; monitorCPU.insert(chest, trinket); Release lock; However, the threads are somehow not abiding by some mutual exclusion condition honored even among thieves. Correct the thread scripts (using a minimum number of corrections) so that they work. The corrected version looks like condition t; // trinket condition lock on chest; Peter and Paul: