CSC413 Tutorial Questions_2023
CSC413 Tutorial Questions_2023
1. Consider five philosopher processes numbered 0 through 4 who spend their lives thinking and eating.
Between each pair of philosophers is a fork. The forks are also numbered 0 through 4, so that fork i is
between philosophers i-1 and i (all arithmetic on forks and philosopher numbers is modulo 5 so fork 0 is
between philosopher 4 and 0). When a philosopher thinks, he does not interact with his colleagues. From
time to time, a philosopher gets hungry and tries to pick up the two forks that are closed to him. A
philosopher may pick up only one fork at a time. Obviously, he cannot pick up a fork that is already in the
hand of his neighbour. When a hungry philosopher is finished, he puts down both of his forks and starts
thinking again. This dining-philosophers’ problem is considered a classic synchronisation problem. Discuss
the various solutions of allocating resources (forks) among several processes (philosophers) in a deadlock-
and starvation-free manner.
2. Unix and Linux operating systems are closely related. It is well believed that Unix is to Linux what DOS is to
Windows. However, there exists differences and similarities between Unix and Linux OSes. Annotatively
differentiate between the two Operating Systems in terms of (i) structure (use diagram) (ii) File systems and
(iii) uses
3. Given the memory configuration in the figure below, answer the following questions. At this point, Job 4
arrives requesting a block of 100K.
i. Can Job 4 be accommodated? Why or why not?
Operating
ii. If relocation is used, what are the contents of the relocation registers for Job 1, Job System 20K
2, and Job 3 after compaction? Job 1 (10K) 30K
iii. What are the contents of the relocation register for Job 4 after it has been loaded
into memory? 50K
iv. An instruction that is part of Job 1 was originally loaded into memory location 22K. Job 2 (15K)
60K
What is its new location after compaction?
v. An instruction that is part of Job 2 was originally loaded into memory location 55K. 75K
What is its new location after compaction? Job 3 (45K)
120K
vi. An instruction that is part of Job 3 was originally loaded into memory location 80K.
What is its new location after compaction?
vii. If an instruction was originally 120K loaded into memory location 110K, what is its new 200K
4. Linux uses an LRU algorithm to manage memory. Suppose there is another page replacement algorithm
called not frequently used (NFU) that gives each page its own counter that is incremented with each
clock cycle. In this way, each counter tracks the frequency of page use, and the page with the lowest
counter is swapped out when paging is necessary. In your opinion, how do these two algorithms (LRU and
NFU) compare? Explain which one would work best under normal use and define how you perceive
“normal use.”
5. Consider a 32-bit machine with 64KB cache, 32B block and two-way set-associative cache, obtain the
offset bits, index bits and tag bits for mapping addresses to frames on this machine.
6. Compare and contrast block, character, and network devices, and how they are manipulated differently
by the Linux device manager.
7. Direct memory access is used for high-speed I/O devices in order to avoid increasing the CPU´s execution
load.
i. How does the CPU interface with the device to coordinate the transfer?
ii. How does the CPU know when the memory operations are complete?
iii. The CPU is allowed to execute other programs while the DMA controller is transferring data.
Does this process interfere with the execution of the user programs? If so, describe what forms
of interference are caused.
9. (i). Discuss how the components of Unix operating systems are interconnected and melded into Kernel.
(ii). What are the features that characterize deadlocks and the three principal methods for dealing with
deadlocks?
(iii). Discuss some of the well-known synchronization problems as examples of a large class of concurrency
control problems.
11. Unix systems used to use disk-layout optimisation based on the rotation position of disk data, but modern
implementations including Linux simply optimise for sequential data access. Why do they do so? Why is
rotational optimisation no longer so useful?
12. Describe the differences among short-term, medium-term, and long-term scheduling.
13. Provide two programming examples in which multithreading does not provide better performance than
a single-threaded solution.
14. Why is it important for the scheduler to distinguish I/O-bound programs from CPU-bound programs?
15. Discuss how the following pairs of scheduling criteria conflict in certain settings.
i. CPU utilization and response time
ii. Average turnaround time and maximum waiting time
iii. I/O device utilization and CPU utilization
16. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds:
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
a. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a non-
preemptive priority (a smaller priority number implies a higher priority), and RR (quantum = 1)
scheduling.
b. What is the turnaround time of each process for each of the scheduling algorithms in part a?
c. What is the waiting time of each process for each of the scheduling algorithms in part a?
d. Which of the schedules in part a, results in the minimal average waiting time (over all
processes)?
17. Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound
tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation
takes 10 milliseconds to complete. Also assume that the context switching overhead is 0.1 millisecond
and that all processes are long-running tasks. What is the CPU utilization for a round-robin scheduler when:
i. The time quantum is 1 millisecond
ii. The time quantum is 10 milliseconds
19. Compare the main memory organization schemes of contiguous-memory allocation, pure
segmentation, and pure paging with respect to the following issues:
a. external fragmentation
b. internal fragmentation
c. ability to share code across processes
20. Write short note on each of the following: (i) process and process state; (ii) process synchronisation and
the synchronisation mechanisms provided by the following operating systems: Windows XP and Linux as
well as Pthreads API (iii) race conditions and semaphore; and (iv) dining philosophers system
21. Five jobs arrive nearly simultaneously for processing and their estimated CPU cycles are, respectively: Job
A = 12, Job B = 2, Job C = 15, Job D = 7, and Job E = 3 ms.
a. Using FCFS, and assuming the difference in arrival time is negligible, in what order would they be
processed? What is the total time required to process all five jobs? What is the average turnaround
time for all five jobs?
b. Using SJN, and assuming the difference in arrival time is negligible, in what order would they be
processed? What is the total time required to process all five jobs? What is the average turnaround
time for all five jobs?
22. Using the process state diagram below, explain why there’s no transition:
a. from the READY state to the WAITING state
b. from the WAITING state to the RUNNING state
23. Consider a system with 13 dedicated devices of the same type. All jobs currently running on this system
require a maximum of three devices to complete their execution. The jobs run for long periods of time
with just two devices, requesting the remaining device only at the very end of the run. Assume that the
job stream is endless and that your operating system’s device allocation policy is a very conservative
one: No job will be started unless all the required drives have been allocated to it for the entire duration
of its run.
a. What is the maximum number of jobs that can be in progress at once? Explain your answer
Explain your answer.
b. What are the minimum and maximum number of devices that may be idle as a result of this policy?
Under what circumstances would an additional job be started?
24. Consider a system with 14 dedicated devices of the same type. All jobs currently running on this system
require a maximum of five devices to complete their execution. The jobs run for long periods of time with
just three devices, requesting the remaining two only at the very end of the run. Assume that the job
stream is endless and that your operating system’s device allocation policy is a very conservative one:
No job will be started unless all the required drives have been allocated to it for the entire duration of its
run.
a. What is the maximum number of jobs that can be active at once?
Explain your answer.
b. What are the minimum and maximum number of devices that may be idle as a result of this policy?
Under what circumstances would an additional job be started?
25. Consider this formula:
G = (A + C2) * (E - 1)3/D + B
a. Show the order that a processor would follow to calculate G. To do so, break down the equation
into the correct order of operations, with one calculation per step. Show the formula for each step,
assigning new letters to calculations as necessary.
b. Find the value of G: if A = 5, B = 10, C = 3, D = 8, and E = 5.
26. Rewrite each of the following expressions for concurrent processing and then code each one. Use the
terms COBEGIN and COEND to delimit the sections of concurrent code. Identify which expressions, if any,
might not run faster in a concurrent processing environment.
a. H2 * (O* (N + T))
b. X * (Y * Z * W * R)
c. M * T * R