11.07.2015 Views

CS 540 Operating Systems Test 2 - Name: Date: Thursday, April 25 ...

CS 540 Operating Systems Test 2 - Name: Date: Thursday, April 25 ...

CS 540 Operating Systems Test 2 - Name: Date: Thursday, April 25 ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>CS</strong> <strong>540</strong> <strong>Operating</strong> <strong>Systems</strong> <strong>Test</strong> 2 - <strong>Name</strong>:<strong>Date</strong>: <strong>Thursday</strong>, <strong>April</strong> <strong>25</strong> , 2002 (in class)Part 1: (40 points - 4 points for each problem)( b ) 1. Which is not a CPU scheduling criterion?(a) CPU utilization (b) Burst time (c) Throughput (d) Response time( a ) 2. Which is a preemptive scheduling?(a) RR (b) FCFS (c) SJF (d) None of the above( a ) 3. If the time quantum is very large, a RR (Round-Robin) scheduling is the same as:(a) FCFS (b) SJF (c) SRTF (d) multilevel queue( b ) 4. Which one is high-level language structure to solve the critical-section problem?(a) <strong>Test</strong>AndSet (b) Monitor (c) Shared memory (d) Semaphore( d ) 5. Which one is not a synchronization problem?(a) Bounded-buffer (b) Readers-Writers (c) Dining-Philosophers (d) None of above( c ) 6. Which is not the necessary condition of a deadlock?(a) Mutual exclusion (b) Hold and wait (c) No starvation (d) Circular wait( d ) 7. Which is not the method for handing deadlocks?(a) Deadlock Avoidance (b) Deadlock Prevention (c) Deadlock Ignorance (d) Deadlock Detention( d ) 8. A computer provides the user with virtual address space of 2 28 words. Pages of size 4096 (2 12 )words If the hexadecimal virtual address is 3456789, the page number in hexadecimal would be:(a) 34567 (b) 6789 (c) 56789 (d) 3456( c ) 9. In paging system where page size is 4096 words, and the available physical memory is equalto 2 24 = 16 M words, the length of the physical address is equal to:(a) 16 bits (b) 22 bits (c) 24 bits (d) 38 bits( a ) 10. When inverted paging is used, we cannot do binary searches on the one global page since:(a) Although the entries are sorted by frame number, we are looking for process-id and matchingvirtual page number(b) The page table is not in sorted order with respect to physical frames(c) The table needs to be implemented as a linked list and it is not convenient to do so(d) None of the above (we can do binary searches)Part 2: (60 points)1. Short Answer: (10 points)(a) Explain the difference between internal and external fragmentation.(b) What type of fragmentation occurs in simple paging systems? Explain.(c) What type occurs in systems that use pure segmentation? Explain.Ans:a) Internal fragmentation is the wasted memory (hole) that is internal to aallocated memory partition. External fragmentation is the wasted memory(hole) that is external to a allocated memory partitions.b) Internal fragmentation occurs in simple paging systems. Because each pagehas the fixed size, holes (unused memory) occur within each page.c) External fragmentation occurs in systems that use pure segmentation.Because each segment has varied size to fit each program size, the holes(unused memory) occur external to the allocated memory partition.


2. Suppose that the following processes arrive for execution at time 0 in the order A, B, C:Process Run Time PriorityA 6 2B 2 3 = lowC 4 1 = high(a) Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a nonpreemptivepriority (a smaller priority number implies a higher priority), and RR (quantum = 2)scheduling.(b) What is the waiting time of each process for each of the scheduling algorithms?(c) What is the turnaround time of each process for each of the scheduling algorithms?(12 points)Ans:a. The four Gantt charts are0 6 8 12 0 2 6 12+---+-+--+ +-+--+---+| A |B| C| FCFS |B| C| A | SJF+---+-+--+ +-+--+---+0 4 10 12 0 2 4 6 8 10 12+--+---+-+ +-+-+-+-+-+-+|C | A |B| Priority |A|B|C|A|C|A| RR+--+---+-+ +-+-+-+-+-+-+b. Waiting time:| FCFS | SJF | Priority | RR---+------+-----+----------+----A | 0 | 6 | 4 | 6B | 6 | 0 | 10 | 2C | 8 | 2 | 0 | 6c. Turnaround time:| FCFS | SJF | Priority | RR---+------+-----+----------+----A | 6 | 12 | 10 | 12B | 8 | 2 | 12 | 4C | 12 | 6 | 4 | 103. Suppose we have 4 processes: A, B, C, and D. A must finish executing before B and C start. B and Cmust finish executing before D starts. Show your solution. Remember to indicate the initial value ofeach semaphore. (10 points)Ans:S1 S2A ----> B ----> D| ^| S3 S4 |+-----> C ------+Then, the processes may be synchronized using semaphores:


semaphore S1, S2, S3, S4 = 0,0,0,0;Process A:----------- do work of AUP(S1); /* Let B start */UP(S3); /* Let C start */Process B:----------DOWN(S1); /* Block until A is finished */- do work of BUP(S2);Process C:----------DOWN(S3);- do work of CUP(S4);Process D:----------DOWN(S2);DOWN(S4);- do work of D4. Consider a swapping system in which memory consists of the following hole sizes in memory order:10K, 4K, 20K, 15K, and 9K. Which hole is taken for successive segment requests of:(a) 8K (b) 12K (c) 10Kfor first fit, best fit, and worst fit. (8 points)Ans: First fit : (a) 10K (b) 20K (c) 15KBest fit : (a) 9K (b) 15K (c) 10KWorst fit : (a) 20K (b) 15K (c) leftover of 20K5. P is a set of processes. R is a set of resources. E is a set of request or assignment edges. The sets P,R, and E are as follows: (10 points)P = {P 1 , P 2 , P 3 } R = {R 1 , R 2 , R 3 } E = {P 1 → R 1 , P 2 → R 2 , P 3 → R 3 , R 1 → P 3 , R 2 → P 1 , R 3 → P 2 }R1 has one instance. R2 has one instances. R3 has one instance.(a) Draw the resource-allocation graph.(b) Is there any deadlock in this situation? Briefly Explain.Ans:b) Consider the resource-allocation graph. One cycle exist in the system.P1 -> R1 -> P3 -> R3 -> P2 -> R2 -> P1P1, P2, and P3 are deadlocked.


6. The time required to read an entry in memory (including the time to access associative memory) is130 nanoseconds when the page number is not in the associative memory. The associative memory canbe accessed in 10 nanoseconds. (10 points)(a) Find a formula that expresses the effective access time as a function of the hit ratio.(b) What hit ratio is needed to reduce the effective access time to 100 nanoseconds?Ans:a) Let E = associative memory lookup timeT = memory cycle timep = hit ratio.Effective Access Time (EAT)= p * (E + T) + (1 - p) * (E + 2 * T)= p * E + p * T + E + 2 * T - p * E - 2 * p * T= (2 - p) * T + EIn this case, E + 2 * T = 130. E = 10. T = 60.EAT = (2 - p) * 60 + 10 = 130 - 60 * pb) 130 - 60 * p = 10060 * p = 30p = 50%

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!