Sie sind auf Seite 1von 14

Operating Systems I

CSCI 4630 Spring 2012


Date: 2nd May. 2012 Name:.......................

FINAL EXAM

Instructions
Please take a minute to read the instructions before beginning to answer the questions. This test consists of three types of questions spread over fourteen pages including this page. The total number of points for the whole test is 100. Points for individual questions are also indicated. The total time allowed is 150 minutes. You may not consult your notes or books. However, you may use a crib sheet. You may use non-programmable calculators. Be sure to write your name. Show all intermediate steps for partial credit. Submit your crib sheet along with the exam, when you are done.

1. Select the most appropriate answer for each of the following questions. No need to provide any justication for your answer. You will get 2 points for each correct answer, 0.5 points for each wrong answer and 0 points for each no answer. (32 Pts.) (a) Which of the following operations should be allowed only in kernel mode? 2 2 2 2 2 (a) Set value of system clock. (b) Read the clock. (c) Turn o interrupts. (d) All of the above. (e) (a) and (c) only. 1

(b) When an interrupt occurs, the interrupt service routine is run. After that: 2 2 2 2 2 2 2 2 2 2 (a) The interrupted process is always restarted. (b) The interrupted process is often restarted. (c) The interrupted process is never restarted. (d) The interrupted process may be restarted. (e) None of the above. (a) Exactly one process is in its critical section at any time. (b) Atleast one process is in its critical section at any time. (c) Only one process may be in its critical section at any time. (d) Only one process may update the variables at any time. (e) None of the above.

(c) Mutual exclusion means:

(d) Using enable/disable interrupts to solve the critical section problem is not a good solution because: 2 2 2 2 2 2 2 2 2 2 (a) It involves busy-waiting. (b) Giving users this privilege is not a good idea. (c) It is dicult to use. (d) All of the above. (e) (a) and (b) only. (a) Are integer variables with an associated queue of processes. (b) Are useful for synchronizing concurrent processes. (c) Are invented by Dijkstra. (d) All of the above. (e) (a) and (b) only.

(e) Semaphores:

(f) Which of the following is most accurate of the wait and the signal operations on semaphores. 2 2 2 2 2 (a) A process doing a wait operation will always get blocked . (b) A process doing a wait operation will never get blocked. (c) A process doing a signal operation will never get blocked. (d) A process doing a signal operation may sometimes get blocked. (e) (a) and (c) only.

(g) Moving processes downward in memory to combine all holes into one big hole is called 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (a) Relocation. (b) Stung. (c) Migration. (d) Compaction. (e) None of the above. (a) One can run large programs. (b) It increases the degree of multiprogramming. (c) It has no overhead. (d) All of the above. (e) Only (a) and (b). (a) Booby Trap. (b) Core Dump. (c) Page Fault. (d) Memory Failure. (e) Segmentation Violation.

(h) Virtual memory is useful because:

(i) Trying to access a page which is not in memory causes an interrupt called a

(j) An algorithm which dynamically allocates page frames among all the runnable processes is called 2 2 2 2 2 (a) Global. (b) Optimal. (c) Unbiased. (d) Local. (e) None of the above.

(k) Which one of the following sets of values are NOT possible for the referenced bit and the modied bit of a page. 2 2 2 2 2 (a) R = 1 and M = 1. (b) R = 0 and M = 0. (c) R = 1 and M = 0. (d) R = 0 and M = 1. (e) None of the above.

(l) I-node: 2 2 2 2 2 (a) Plays a pivotal role in UNIX le systems. (b) Plays a pivotal role in all operating systems. (c) Contains the name of the le. (d) All of the above. (e) Only (a) and (c).

(m) The time required to move the read/write head of the disk arm so that it is on the desired track is called 2 2 2 2 2 (a) move time. (b) modication time. (c) seek time. (d) rotational delay. (e) data transfer time.

(n) Which one of the following system calls can be used to gather information about a le in UNIX. 2 2 2 2 2 (a) open. (b) seek. (c) chown. (d) chmod. (e) stat.

(o) Which one of the following is NOT a valid system call dealing with directory operations: 2 2 2 2 2 2 2 2 2 2 (a) opendir. (b) closedir. (c) readdir. (d) writedir. (e) None of the above. (a) creation time. (b) size of le. (c) link count. (d) modication time. (e) none of the above.

(p) Which of the following is NOT a le attribute?

2. Answer exactly 8 of the following 10 short questions in the space provided. Be up to the point, but not necessarily brief. In other words, be precise, but not necessarily concise. (8 * 5 = 40 pts.) (a) What are the desirable properties of a good solution to the critical section problem? List them and briey explain each one of them.

(b) What is meant by busy waiting? Is it good or bad? If so, why so and If not, why not? Does Petersons solution to the 2-process critical section problem involve busy waiting or not?

(c) What is meant by external fragmentation and internal fragmentation? Give an example of each.

(d) What is meant by translation lookaside buer? What is its importance?

(e) Describe the second chance page replacement algorithm.

(f) Consider an MVT system in which memory consists of the following hole sizes in memory order: 4K, 7K, 10K, 5K, 15K, 25K, 9K, 12K. Which hole is selected when a new process of size 8K needs to be accommodated and the rst t algorithm is used? Repeat the question for best t and worst t.

(g) Some operating systems provide the system call RENAME to give a le a new name. Compare using this call to rename a le, and just copying the le to a new le with the new name, followed by deleting the old one. Discuss the similarities and the dierences (if any) between the two ways.

(h) Describe the Linked List Allocation Method of Implementing Files. Mention couple of advantages and a couple of disadvantages of this scheme.

(i) To open the le /usr/sta/gopal/cs4630/exam3.tex, several disk accesses are needed. Calculate the number of disk accesses required under the assumption that the i-node for the root directory is always in memory, all the directories are 1 block long and no block that you are looking for is in the Cache Memory. Dont just specify the nal answer. Mention the purpose of each one of your disk access.

(j) Describe as to how le sharing can be achieved using hard links. Discuss the pros and cons of this method of le sharing.

3. Answer exactly 2 of the following 3 long questions in the space provided. Show all intermediate steps and your work. (2 * 14 = 28 pts.) (a) This question is on dining philosophers problem. Please refer to the solution given in a separate sheet. i. In the take forks procedure, the state variable is set to HUNGRY and then the test procedure is called. In the test procedure, it is checked among other things as to whether state[i] is HUNGRY. Obviously, this would be true. Why do we do this checking also? What would be the consequences of dropping state[i] == HUNGRY in the test procedure? (5 Pts.)

ii. Consider the procedure put forks in the solution to the dining philosophers problem. Suppose that the state variable state[i] was set to THINKING after the two calls to test, rather than before. How would this change aect the solution? (4 Pts.)

10

iii. Dr. Smart Alec argues that the function test involves accessingthe shared variable state and therefore the code in it should be enclosed between down(& mutex) and up(& mutex). Is it necessary to do so? Would there be any harm done if his suggestion is adopted? (5 Pts.)

11

(b) Assume a paged memory system with 16 page frames. Size of a page frame is 1024 bytes. Assume that the size of the virtual address space of a process is 8192 bytes. A global LRU algorithm is used for page replacement. The page table of the currently running process (pid = 10) and a frame table showing the usage of the page frames are shown below. For the sequence (one after the other) of memory addresses given after the tables answer the following three questions. i. Determine whether the attempted access will cause page fault or not. ii. If a page fault will be caused, determine the frame number where the page currently requested by the process will be loaded by the operating system. iii. Determine the corresponding physical address.

Valid Frame No.


0 1 2 3 4 5 6 7 1 1 0 1 0 0 1 0 11 7 14 5 3 9 6 8

The Page Table for Process 10

Free Process Id Page No. Loaded Last Ref


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 7 6 2 11 2 10 10 10 7 7 6 10 2 2 7 6 3 5 4 4 6 3 6 1 4 7 6 0 3 1 2 2 25 57 70 77 88 42 44 99 33 14 28 60 47 52 56 123 120 110 112 115 170 100 117 118 111 46 61 70 80 81 82 180

The Frame Table

12

i. Virtual Address = 1456.

ii. Virtual Address = 2673.

iii. Virtual Address = 5256.

iv. Virtual Address = 5728.

13

(c) Solve the following two problems about UNIX File Systems. The two problems are independent of each other. For both of them assume that a UNIX i-node has 10 disk addresses for data blocks, as well as the addresses of single, double and triple indirect blocks. i. Assuming the block size is 1KB and the block addresses are 4 bytes long, nd the size of the largest le that can be handled. (7 Pts.)

ii. A UNIX program creates a le that is 20,000,000 bytes long. Calculate the total number of blocks the le occupies, including indirect blocks if any. Assume that the capacity of the disk is 64MB and block size is 1 KB. (7 Pts.)

14

Das könnte Ihnen auch gefallen