Comp 104: Operating Systems Concepts Mock Exam Questions
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
Exam Question 1 • Which of the following is/are valid responses that a UNIX process can make on receipt of a signal? • The process can ignore the signal • The process can perform a default action such as terminating • The process can specify a handling routine for dealing with the signal • III only • I and III only • II and II only • I and II only • I, II and III • Answer:e • TRUE. By default, signals may trigger some action, such as hangup or interrupt. However, the process can catch these and ignore them. • TRUE. see above • 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.
Exam Question 2 • The value of a semaphore s is initially 1. What could happen in the following situation? T1 T2V(s); P(s);critical regioncritical regionP(s); V(s); • Deadlock will ensue • T1 and T2 can both enter their critical regions simultaneously • Neither T1 nor T2 can enter its critical region • T1 can never enter its critical region, but T2 can enter its own • T1 can enter its critical region, but T2 can never enter its own • Answer: b • If T1 executes first, then it acquires the semaphore, which is immediately released by T2. Both then execute the critical region. • If T2 executes first, it releases a semaphore it does not have, which can be acquired by T1. Again, both can execute the critical region.
Exam Question 3 • Consider the following Gantt chart showing the CPU burst times (in milliseconds) of three processes using the round robin scheduling algorithm: • Suppose the three processes, P1, P2 and P3, 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? • 5.6 milliseconds • 7.67 milliseconds • 9.33 milliseconds • 23.67 milliseconds • 33 milliseconds P1 P2 P3 P1 P1 P1 0 5 9 14 19 24 28 • Answer: b • Average Wait Times for each process: • P1: 14-5 = 9 • P2: 5 • P3: 9 • Total Average Wait Time: (9+5+9)/3 =23/3
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 Actual Page0 3 1 -2 43 0 • A virtual address of [0, 200] maps on to an actual address of? • 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. 1124 2872 3272 4096 None of the above
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 A9B3. How many blocks are free? • 4 • 7 • 9 • 11 • 16 • Answer: b • Hexidecimal value A9B3 is 1010 1001 1011 0011 • Each 0 represents a free block. • As there are 7 zeros, there are 7 free blocks.
Exam Question 6 • Which of the following is NOT usually represented in a subroutine’s data frame for a stack-based programming language? • 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
Exam Question 7 • A paricular BNF definition for a “word” is given by the following rules: <word> ::= <letter>|<letter><pairlet>|<letter><pairdig> <pairlet> ::= <letter><letter>|<pairlet><letter><letter> <pairdig> ::= <digit><digit>|<pairdig><digit><digit> <letter> ::= a|b|c|…|y|z <digit> ::= 0|1|2|…|9 • Which of the following lexical entities can be derived from ⟨word⟩ ? • note • notes • c22 • I and II only • I and III only • II and III only • I, II and III • None a := (2 + b; • A Syntax Error. • A Static Semantic Error. • A Dynamic Semantic Error. • A Warning, rather than an error. • None of the above. • Answer: c • The definition of word requires any <pairlet> or <pairdig> to be preceded by a <letter>. • FALSE: “note” has four letters • TRUE: <letter><pairlet><pairlet> • TRUE: <letter><pairdig>
Exam Question 8 • Which code optimisation technique could be applied in the following piece of code? a = (20+10*2)/4; • 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