Comp 104 Operating Systems Concepts Mock Exam Questions










- Slides: 10
Comp 104: Operating Systems Concepts Mock Exam Questions 1
Notes on the Exam • Exam will be a multiple choice paper – Duration: 2 hours – Number of Questions: 50 • Each question will have five statements which involve identifying: – the one correct statement – the correct combination of valid statements 2
Exam Question 1 • Which of the following is/are valid responses that a UNIX process can make on receipt of a signal? I. The process can ignore the signal II. The process can perform a default action such as terminating III. The process can specify a handling routine for dealing with the signal a) b) c) d) e) III only I and III only II and II only I, II and III Answer: e 1. TRUE. By default, signals may trigger some action, such as hangup or interrupt. However, the process can catch these and ignore them. 2. TRUE. see above 3. TRUE. As well as ignoring a signal, a process could do other actions. For example, when receiving an interrupt, a process might close files and save state before interrupting. 3
Exam Question 2 • The value of a semaphore s is initially 1. What could happen in the following situation? T 1 V(s); critical region P(s); a) b) c) d) e) T 2 P(s); critical region V(s); Deadlock will ensue T 1 and T 2 can both enter their critical regions simultaneously Neither T 1 nor T 2 can enter its critical region T 1 can never enter its critical region, but T 2 can enter its own T 1 can enter its critical region, but T 2 can never enter its own Answer: b If T 1 executes first, then it acquires the semaphore, which is immediately released by T 2. Both then execute the critical region. If T 2 executes first, it releases a semaphore it does not have, which can be acquired by T 1. Again, both can execute the critical region. 4
Exam Question 3 • Consider the following Gantt chart showing the CPU burst times (in milliseconds) of three processes using the round robin scheduling algorithm: P 1 0 • P 2 5 P 3 9 P 1 14 P 1 19 P 1 24 28 Suppose three processes, P 1, P 2 and P 3, all arrive at time 0 and we are using a time quantum of 5 milliseconds. Assuming we are not including time for performing context switching, what is the average waiting time in the above example? Answer: b a) 5. 6 milliseconds Average Wait Times for each process: b) 7. 67 milliseconds P 1: 14 -5 = 9 c) 9. 33 milliseconds P 2: 5 d) 23. 67 milliseconds P 3: 9 e) 33 milliseconds Total Average Wait Time: (9+5+9)/3 =23/3 5
Exam Question 4 • The lookup page table shown below is for a job in a paged virtual storage system with a page size of 1024 locations. Each virtual address is of the form [p, d] where p and d are the page number and the displacement in that page, respectively Virtual Page 0 1 2 3 Actual Page 3 4 0 • A virtual address of [0, 200] maps on to an actual address of? a) b) c) d) e) 1124 2872 3272 4096 None of the above Answer: c The address corresponds to 200 locations offset from Virtual Page 0. Virtual page 0 is actually 3 pages from the beginning of the address space. As each page is 1024 locations long, this address is 3072. So an offset of 200 locations from this is 3272. 6
Exam Question 5 • A filestore allocation system uses a bit string to record the use of its blocks, with 0 denoting free and 1 denoting allocated. A 16 -bit segment of this string has the hexadecimal value A 9 B 3. How many blocks are free? a) b) c) d) e) 4 7 9 11 16 Answer: b Hexidecimal value A 9 B 3 is 1010 1001 1011 0011 Each 0 represents a free block. As there are 7 zeros, there are 7 free blocks. 7
Exam Question 6 • Which of the following is NOT usually represented in a subroutine’s data frame for a stack-based programming language? a) b) c) d) e) Values of locally declared variables A heap area The return address A pointer to the calling activation record Parameter values passed to the subroutine Answer: b A heap area 8
Exam Question 7 • A paricular BNF definition for a “word” is given by the following rules: <word> : : = <letter>|<letter><pairlet>|<letter><pairdig> <pairlet> : : = <letter>|<pairlet><letter> <pairdig> : : = <digit>|<pairdig><digit> <letter> : : = a|b|c|…|y|z <digit> : : = 0|1|2|…|9 • Which of the following lexical entities can be derived from �word�? I. note II. notes III. c 22 a) b) c) d) e) I and II only I and III only I, II and III None Answer: c The definition of word requires any <pairlet> or <pairdig> to be preceded by a <letter>. I. FALSE: “note” has four letters II. TRUE: <letter><pairlet> III. TRUE: <letter><pairdig> 9
Exam Question 8 • Which code optimisation technique could be applied in the following piece of code? a = (20+10*2)/4; a) b) c) d) e) Code Deletion Strength Reduction Constant Folding Global Register Allocation Peephole optimisation Answer: c The expression consists of constants, and thus can be computed to produce a single constant. If the expression had contained variables, then Strength Reduction could be used instead, e. g. : a = b * 2 can be reduced to a = b + b a = a / 4 is a right shift operation: a = a >> 2 10