Answers to MT 2, Fall 1998 CS61c question 0. Surprisingly, some of you failed to circle your login name and lost a point. Again. Why do we do this? Your handwriting is of course perfectly legible. But some of your friends have bad handwriting... Out of 300 papers we get as many as 10 papers for which we misread the login names (because what you wrote looks like cs61c-uv to us. But you wrote cs61c-mn. etc.) You can image that this causes considerable problems. So we tried to solve this problem by technology.. question 1 (7 points) we expected you to draw SIX full adders with the inputs being x7 x5, x6 x4 ....... , x2 x0 x1 x0 | | | | | | | | + + + | | with wires connecting x1 to sum1 and x0 to sum0 (no adders needed to add 0 to something!) (you also have to put carry lines in the obvious places) If you used 6 or 8 adders: 2 points If you connected the output to the results of the particular example and got 200 decimal 110010000 : 2 points If you shifted the input correctly 2 points Lack of any obvious other flaws 1 point question 2 (2 points) a. Pointers can be abbreviated in memory and some `cons cells' can take 1 word instead of 2. b. Some answers we accepted; CDR-coding improves spatial locality. It is faster because you can load a whole cell into a register in one load. CDR-coding saves memory (see part a), and though it is cheap, it is not free. question 3 (10 points) offset set tag 3 2a3 a2ec4 f 8 a2ec4a f - 5176254 question 4 a 256 (2 pts) b 32 (2) c 2-way (1 pt) this is tough, so we made it worth less. We did not give any credit for "n-way". We did not look at the row/columns circled. d. The correct answer is something like: cache.c ran the test many times and computed the average. (2 pts) Some of you said that we ran it on a simulator, or that we used mathematical formulas or that we ran it in kernel mode. These did not get any credit because they were wrong. But if you think they make any sense, bring it up in discussion section. Question 5 (1 each) a = but we allowed up in case you read block instead of byte offset. b up c = d up e up f up g up h down i down j up There was not much of a pattern in what people got wrong here. If you need an explanation, ask someone else. There is a good chance he/she got it right, and maybe knows the correct reason too! Question 6 (5 pts total) a (1 pt) lui $1, 0x0055 ori $8, $1, 0x4444 only 2 instructions, not 3, or more b (1 pt) lui $1, 0x0155 ori $8,$1,0x8444 only 2 instructions, not 3, or more c. branches are PC relative, and the offset doesn't change if you move the instruction. d. (2 pts) values in .data may contain absolute locations in the data or text segment. when they are moved, they must be relocated. (example: jump table in .data) question 7 (8: 2 pts each) Some people had interrupt driven I/O in mind when they answered this question about ASYNCHRONOUS output (chapter 11 in G&M) a. User program calls F1 when it needs to write out something. b. the operating system calls F2, occasionally. (user program can also call F2, and maybe even should, at the end of F1, but this is not sufficient). c. F2 does nothing if device not ready or buffer empty. d. Many answers were possible. We looked for words like security, needed access to I/O operations (though not strictly necessary for all syscalls), OS process control, making this process wait question 8 (5 pts 1 each) a. Arg 1 is onn top of stack 0($sp) or 0($29). $A0 was wrong. b. On the stack at 4($sp), 8($sp) etc. Just "on the stack" was wrong if you answered $A0 for a. c. Extra arguments are ignored. d. Extra directives makes the sprintf program try to operate on whatever stuff is on the stack. This might be kind of "random" stuff, or might involve illegal memory references, possibly crashing your program. e. No, there is no way to check the argument count by changed sprintf. the sprintf program would have to know how many arguments were passed on the stack, and we have not provided any means for this information to be conveyed. Question 9 (1 each) a. sample correct answers: address and data acquire and transfer request and transmit a. synchronous is likely to suffer from skew if made too long. b. The cause register explains why an interrupt occurred. c. We gave most people credit if the UNITS were plausible. disk latency should be about 10-20 milliseconds (ms). bandwidth should be something like 2 megabytes per sec (Mb/s). We did not give credit if you your numbers were off by too many orders of magnitude. E.g. 2 seconds or 2 nanoseconds latency for a hard disk suggests you do not know what latency means.