CSE 430 Midterm 2: OS - Scheduling, Sync, and Process Coordination, Exams of Operating Systems

The questions and answers for the midterm exam of cse 430 - operating systems course held in fall 2006. The exam covers topics such as scheduling algorithms (shortest remaining time first, preemptive priority, round robin), process synchronization using testandset hardware instruction, and process coordination using semaphores and monitors.

Typology: Exams

Pre 2010

Uploaded on 09/02/2009

koofers-user-yum
koofers-user-yum 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 430
FALL 2006 MIDTERM 2 NAME
1. (30) Scheduling
Given the following processes:
Process # Arrival Time Run Time Priority (1 is highest)
A 0 5 3
B 1 3 2
C 3 2 1
(20) (a) Draw a Gantt chart to illustrate the execution of these processes for each of the following
4 CPU scheduling algorithms: Shortest Remaining Time First; Preemptive Priority; Round
Robin with q=2 and FCFS.
(b) (5) What is the average waiting time for Round Robin with q=2?
(c) (2) What scheduling algorithm does round robin approach as the quantum size approaches
infinity?
(d) (3) What determines the practical lower bound on the time quantum for Round Robin process
scheduling and why is this so? Note: the answer is not a ‘rule of thumb’.
pf3
pf4

Partial preview of the text

Download CSE 430 Midterm 2: OS - Scheduling, Sync, and Process Coordination and more Exams Operating Systems in PDF only on Docsity!

CSE 430

FALL 2006

MIDTERM 2 NAME

1. (30) Scheduling Given the following processes: Process # Arrival Time Run Time Priority (1 is highest) A 0 5 3 B 1 3 2 C 3 2 1 (20) (a) Draw a Gantt chart to illustrate the execution of these processes for each of the following 4 CPU scheduling algorithms: Shortest Remaining Time First; Preemptive Priority; Round Robin with q=2 and FCFS. (b) (5) What is the average waiting time for Round Robin with q=2? (c) (2) What scheduling algorithm does round robin approach as the quantum size approaches infinity? (d) (3) What determines the practical lower bound on the time quantum for Round Robin process scheduling and why is this so? Note: the answer is not a ‘rule of thumb’.

CSE 430

FALL 2006

MIDTERM 2 NAME

2. (17) Synchronization Hardware Boolean lock; while (true) { while ( TestAndSet (&lock )) ; /* do nothing // critical section lock = FALSE; // remainder section } Shown above are two ways the TestAndSet hardware instruction can be used to insure mutual exclusion. (a) (3) What advantage does the solution on the right have over the solution on the left? (b) (6) Show that the solution on the right meets the mutual exclusion requirement for the solution to the critical section problem. (c) (8) Show that the solution on the right meets the bounded waiting requirement for the critical section problem. Include in your answer what the upper bound on the waiting time for a process that wants to enter the critical section is. Boolean waiting[n]; Boolean lock; do { waiting[i] = TRUE; key = TRUE; while (waiting[i] && key) key = TestAndSet(&lock); waiting[i] = FALSE; // critical section j = (i+1) %n; while ((j != i) && !waiting[j]) j = (j + 1) %n; if (j == i) lock = FALSE; else waiting[j] = FALSE; // remainder section } while (TRUE);

CSE 430

FALL 2006

MIDTERM 2 NAME

4. (15) Threading Issues In a multithreaded program, if one thread calls fork() , whether one or all the threads should be duplicated in the new process depends upon whether the new process invokes exec() immediately after the fork(). Explain why this is true and state in which case it makes sense to duplicate just the thread that invoked the fork() and in which case it makes sense to duplicate all the threads in the parent process. 5. (10+3 points extra credit) More Scheduling (a) (5) The Solaris scheduling algorithm discussed in the text decreases the priority of a thread that used its entire time quantum without blocking and increases the priority of a thread when it returns from sleep. State why does it does one of these? (b) (5) The Linux 2.6 scheduler is an O(1) complexity routine as against its predecessor in Linux 2.4 that was an O(n) scheduler where n is the number of ready processes. Explain why the Linux 2.4 scheduler was O(n). (c) (3 points extra credit) What change did the Linux developers make that changed the scheduler to an O(1) scheduler. Hints: It’s not introducing a separate run queue per processor or the mechanism for speeding up swapping the expired array with the active array at the end of an epoch. 6. (5)Monitors and semaphores Give an advantage monitors have over semaphores.