2003 Test and Answers
2003 Test and Answers
Question 1.
There are two major design types for operating system kernels: monolithic kernels and microkernels.
Which of these types better satisfies the following requirements? If both are equally as good write
both. Justify your answers.
a) Convenient access to operating system data structures.
Monolithic – access from any part of the kernel to any other part is possible. With a microkernel
access is via message passing.
/* testForkExample.c */
main() {
int i = 0;
printf("main pid: %d\n", getpid());
while (i < 3) {
int childpid = fork();
if (childpid != 0)
printf("%d. childpid: %d\n", i, childpid);
i++;
}
}
The program produced the following output when run from a terminal on my machine:
pid:3260
pid:3267
Other acceptable answers have 3265, 3266 and 3267 swapped amongst themselves. The others
must be in these places.
6 marks
b) Explain why the last four lines of output are produced after the command line prompt
[robert@icicle Documents]$ reappears.
The prompt can reappear as soon as the testForkExample process itself has finished. The shell
waits for any process it starts to finish it does not wait for children of that process to finish. All
other lines of output come from the children.
2 marks
Question 3.
a) In the lectures it was mentioned that priorities make real-time scheduling more difficult. Give a
reason why priorities are still used in real-time systems
Priorities can be used to indicate how important tasks are. In this way we can ensure that more
important tasks are handled before less important ones.
2 marks
b) Here is a diagram from the textbook:
Processes enter the scheduler in the level 1 queue and move down a level if they completely use their
time-slices. Processes do not move up levels. Preemption only occurs when the time-slice is
completed.
This list of processes shows CPU burst times. The processes start in this order in the level 1 queue.
Using the information above complete this table showing: the order of process scheduling; the queue
the process was selected from; and how long each process runs.
5 marks
b) There is something very wrong with this scheduler. What is it and how can it be fixed?
When processes descend to level 3 the system can be locked up by a level 3 process running in an
infinite loop.
Fix it by giving level 3 processes a long but fixed time-slice and scheduling them round-robin.
2 marks
Question 7.
The semaphore wait and signal operations are defined as indivisible (or atomic) operations.
a) Why do they have to be indivisble?
If they weren't indivisble it would be possible for multiple waits and signals to occur simultaneously
(on a multiprocessor) or at least interleaved with each other. This would corrupt the value of the
semaphore and prevent it working properly.
4 marks
b) Because they are indivisible does that mean that all other processes running on a multiprocessor
system must stop when a wait or signal operation is executed? Explain why or why not.
No. Strictly only processes accessing the same semaphore at that time need to stop. Any processes
not wanting to change or access the semaphore should be allowed to continue.
4 marks
Question 8.
a) Describe a scheme to implement mutual exclusion in a distributed environment. Say how a process
requests exclusive access to the resource, how that exclusive access is maintained and how the
resource is made available to a new process when the current one has finished with it.