You are on page 1of 4

MINOR 1 (2010) (EEL358) OPERATING SYSTEMS Time: 1 Hours Max.

Marks: 25

-------------------------------------------------------------------------------------------------------NAME: Entry No. --------------------------------------------------------------------------------------------------------N. B.: This is open book/notes examination, but transfer of notes to each other is strictly prohibited.

Q1:- Consider the following set of processes with arrival times and CPU execution times given in milliseconds. A process with a larger priority number has a higher priority. State any assumptions that you make. (4 + 2)

a):- Draw and label Gantt charts illustrating the execution of these processes using: i):- RR scheduling with a time quantum of 4 msec. 1 1 2 3 1 4 2 5 3 4 2 5 3 4 2 5 3 4 2 5 3

ii):- Non-preemptive SJF scheduling.

12 25 40 59 80 b):- Calculate the average waiting times for schedules (i) and (ii) above, ignoring priority values. Which method gives a better waiting time for this data? (i) AWT = (sum of (Finish arrival length) for all processes) / # of processes = ((20 0 12) + (72 5 -19) + (80 8 - 21) + (69 11 13) + (75 15 15)) / 5 = 197 / 5 = 39.5 m. sec. (ii) AWT = ((12 0 -12) + (59 5 19) + (80 8 21) + (25 11 13) + (40 15 15)) / 5 = 97 / 5 = 19.4

1/4

Q2:- Consider the following system snapshot using the data structures in the Banker's algorithm, with resources A, B, C, and D, and processes P0 to P4: (2 + 2 + 3)

Using the Banker's algorithm, answer the following questions. While executing the Banker's algorithm, if there are multiple processes that may complete on a given cycle, please choose the one with the lowest index. (a) What are the contents of the Need matrix? NEED A B C D P0 3 0 2 0 P1 0 5 5 0 P2 2 3 0 1 P3 1 1 4 1 P4 2 1 2 0 (b) Is the system in a safe state? Why? Write the sequence, if any and mention availabilities after the process completes. AVAILABILITY A Before After P0 After P4 After P2 After P1 After P3 3 7 7 8 9 9 B 2 2 5 5 6 10 C 2 2 3 7 7 9 D 1 2 4 9 9 10

Discussion of result (in less than 20 words): Yes, matches no. of resources of type A, B, C and D. The order P0, P4, P2, P1, P3 can satisfy. (Most probable order) 2/4

(c) If a request from process P2 arrives for additional resources of (0,2,0,0), can the Banker's algorithm grant the request immediately? Why? Show the new system.

P0 P1 P2 P3 P4

7 0 1 6 3 3 1 5 2 4

2 1 5 4 6 3 0 6 2 2

4 1 1 0 0

0 1 2 4 3

0 1 0 0 4 5 2 1 1 2

3 0 2 1 2

0 2 0 5 5 0 1 0 1 1 4 1 1 2 0 3 0 2 1

Discussion of result (in less than 30 words): This state is not safe. P0 can be satisfied but
the available resources at that point (7 0 2 2) can not satisfy the needs of the remaining processes. Q3:- 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.1millisecond and that all processes are long-running tasks. What is the CPU utilization for a round-robin scheduler when: a. The time quantum is 1 millisecond b. The time quantum is 10 milliseconds (3) ANSWER: (a) :- The time quantum is 1 m. sec. irrespective of which process is scheduled, the scheduler incurs a 0.1 m. sec. context switch cost for every context switch. This results in a CPU utilization of (1 / 1.1) * 100 = 0.9090 (91 %) (b) :- The time quantum is 10 m. sec.. The I/O bound tasks incur a context switch after using up only 1 m. sec. of time quantum. The time required to cycle through all the processes is therefore 10 * 1.1 + 10.1 (As each I/O bound task executes for 1 m. sec. and then incur the context switch task. Whereas the CPU bound task executes for 10 m. sec. before incurring a context switch. The CPU utilization then = (20 / 21.1) * 100 = 95 %

3/4

Q4:- Mark the statements with [] and [X] for correct and wrong statements. 2 errors in marking will be ignored: (9) Starvation implies that deadlock has occurred. [X ] Monitors can deadlock. [ ] The registers for I/O devices are part of the context of a process. [X ] As the ratio of time slice to job length decreases, round-robin CPU scheduling becomes equivalent to first-come-first-serve. [X ] When running on a multiprocessor, it will make sense to have a spin lock also disable interrupts for the duration of a critical section. [ ] Among CPU scheduling policies, First Come First Serve (FCFS) is attractive because it is simple to implement. [ ] Among CPU scheduling policies, Shortest Remaining Processing Time (SRPT) is attractive because it minimizes the average waiting time in the system. [ ] Context switch overhead of a user-level thread is less than the overhead for processes. [ ] An atomic operation is a machine instruction or a sequence of instructions that must be executed to completion without interruption. [ ] Deadlock is a situation in which two or more processes (or threads) are waiting for an event that will occur in the future. [X] While a process is blocked on a semaphore's queue, it is engaged in busy waiting. [X] Circular waiting is a necessary condition for deadlock, but not a sufficient condition. [ ] Mutual exclusion can be enforced with a general semaphore whose initial value is greater than 1. [X] In a symmetric multiprocessor, threads can always be run on any processor. [X] The threads of a multithreaded process share heap memory and global variables. [ ] There is no performance benefits associated with executing multiple user-level threads on a multiprocessor system. [ ] First come first serve (FCFS) and priority based scheduling results in starvation. [X] If processes do not perform I / O, round-robin scheduling policy resembles shortest time to go (STG) scheduling. [X] If processes do not perform I / O, the Unix scheduling policy degenerates to the conventional round-robin scheduling policy. [ ] The threading model supported by the typical Linux kernel is one-to-one. [ ] A CPU-bound process makes almost constant use of the CPU. [ ]

4/4