1) There is an error on line 3 - return with no value. This is legal in C but only for void functions. This function is supposed to return an int. Line 5 is a declaration but we have had code already. This is a mixed declarations and code error in ansi-C Line 7 has a c++ comment on it - Legal in c99 but not in ansi C this gives an answer of (J) 2) add needs one as does remove. This rules out a,b,f,i This leaves, status, update, diff. That is, c,d,e,h,j The only reason not to pick (H) is if you think one of those requires a commit. (None of them do) Commit goes to the repository update comes from the repository. status and diff work on your working copy. 3) The answer is none of the above for two reasons. First (the intended one): all the output is sent to standard error. I've been very careful in lectures to always say that shell pipes connect the _standard out_ of a process to the standard input of the next process. The pipe has no effect on standard error. In this situation, everything printed will be displayed on the console. secondly, consider what happens to i==0. 0%2 is 0 which is false. so it would print out 0 is odd. 4) The order for grep is grep _thing_to_look_for_ _files_to_search_ The second param is optional, if it is omitted, then grep reads from standard in. All this should be fairly clear from the man page for grep [grep was on the list of commands you needed to know]. a- wrong because it searches for data in a file called fish. b- wrong because it does the tail first. so would find the 7th last not the 7th from the beginning. c- wrong it finds the 7th line but does not check if it contains fish until afterwards. This will either display the 7th line if it happens to contain fish or nothing. d- correct. [remember grep can read from standard in]. e- will read from standard in rather than from the file. Apart from that it's correct. f- again reads from standard in. 5) Some people had trouble with the mixed = and == This is legal in the same way you can mix + and - The precedence chart in lectures shows that == has higher precedence so it will be evaluated first. so if (x=y==z) becomes (x=(y==z)) (x=(3==2)) (x=0) (0) so the if is false z=9 (and x==0) The semi-colon after the if is legal [it's just an empty statement] so w=7 in all cases. This leaves (C) as the answer. 6) Again people were unhappy with the idea of mixing operators (++ vs - ). This is legal. You are also allowed to have cases without break - this was explained in lectures. In such cases you just keep executing until you hit a break. The value of the expression in the switch expression is: 4-2 == 2 (The ++ has the side effect of changing i to 5.) We enter the switch at the 5 label and i->7 We drop into the default case which takes i to 12. This gives the answer of (f) 7) As explained in lectures, the * only affects the variable directly on its right. So splitting the declarations up we get: long* var; long foo[7]; long baz; This gives the answer (B) 8) The question asks for a _function_ which ..... alternative b was: char *foo(char(*)(char)) In lectures I said that the position of the spaces around the * does not matter. So char* x is the same as char *x. so b is equivalent to char* foo(char(*)(char)) The rest of the answers were all _function pointers_ not functions. 9) You needed to notice that px points to y and py points to x *px=x+y ==> y=x+y so y=5 z=5 (which it was already) x=y-x ==> x=y-2==3 so x=3, y=5, z=5 *px=y-*py ==> y=y-x ==> y=5-3==2 so x=3, y=2, z=5 So the answer is (C) 10) px is not initialised. That doesn't necessarily mean it points to an invalid page. It _could_ be anything. That is the problem is uninitialised values. Correct answer (G) we can't be certain. 11) The difficult part here is that when f(2) is called it forks so two processes return to f(3). The best way to deal with this is just to draw a picture. Please see my diagram linked in the exam area. The answer was (F) - 7 12) As I said in lectures - zombies are always created. They might not be around for very long but they are always made. (E) - none of the above. ---- The last three questions need the system information from the front of the exam paper ---- 13) Step one is to work out which pages the addresses fall in. pages are 4KB (4096) so we (integer) divide each address by 4096. 45055 ==> 10 45056 ==> 11 8392710==> 2049 45090 ==> 11 8392714 => 2049 45091 ==> 11 First location: to access this location we will need to find its physical address. This means refering to the page table. There are two levels to the page table so we need two memory accesses to find the first location and one to do the access itself. BUT now that mapping is in the TLB. The next two addresses will each require 3 memory accesses (for the same reason). So we have done three and are currently at a total of 9 accesses. Now we have three more addresses but they are all in the TLB now so they don't need additional lookups. Gives a total of 12. Answer=G 14) (I suspect) A lot of people made a simple error here. We know that for a 32bit virtual address space we will need 2^32/2^12 == 2^20 pages. We know that each page can hold 4KB/4B entries. So we need 2^20/2^10 pages worth of 2nd level table. Which is 1024 table pages. Each page is 4K so total pages take up 1024*4K which is 4096K (_of second level table_) You need to add an extra 4K to allow for the 1st level table. So the answer is (C) 4100K 15) The table will always map virtual to physical. The first step is to split the virtual address into page and offset: 500 = 500/4096 ; 500%4096 = 0 ; 500 8200= 2 ; 8 102400=25;0 Now page 0 maps to page 200 so 500 maps to 200*4096+500=819700 Hmm ok that leaves (b) and (d) as options so far. page 25 maps to frame 24 which starts at 98304 So that rules out all the normal options. Page 2 is valid, page 0 is valid and page 25 is valid So that rules out page and segmentation faults. The only option left is none of the above.