| CS 354, version A Fall 2003 | Name:___________________ ID:___________________ Login:_____________________ | |
| Exam 3 | ||
|
No electronic devices may be used while taking this exam. Examples of devices not allowed are calculators, pagers, cell phones, wrist calculators/computers, laptop computers, pocket computers. Each student is allowed one 8.5 by 11 inch sheet of paper with handwritten notes. The notes may be on both sides of the paper. Show all work, and do any/all calculations on the exam. Extra scratch paper may not be used. |
Exam Score Q 1 = _____ / 8 Q 2 = _____ / 4 Q 3 = _____ / 8 Q 4 = _____ / 8 Q 5 = _____ / 4 Q 6 = _____ / 6 Q 7 = _____ / 9 Total = _____ / 47 |
Question 1 (8 points)
Perform the following IEEE single precision floating point addition.
Use standard rounding (to nearest, with even as tie-breaker).
Show your work. Put your final answer back into hexadecimal.
0x55f10004
+ 0xd3fe0007
------------
Question 2 (4 points)
In Program 4, we used a simple spin wait loop without
buffering in the kernel to implement a
single character of keyboard input.
Identify a specific error situation that can occur due to this
implementation if a user enters many characters.
Explain the problem with a possible error and how to fix it.
Question 3 (8 points total)
Part A (2 points)
Distinguish a trap from an interrupt.
Part B (2 points)
We want to add a new I/O device to a MIPS computer system.
What HW do we need to change?
What SW do we need to change?
Part C (4 points)
Why are interrupts disabled upon entry to the kernel? (IEc is cleared.)
What specific problem does this prevent?
Question 4 (8 points total)
When an exception occurs, the MIPS hardware saves the program counter
active just before the exception.
Part A (3 points)
How is this done? Why is it not saved in $31 (like for
a jal instruction)
or another normal register ($0-$30)?
Part B (5 points)
After handling an exception due to a syscall, the kernel
usually returns to a program counter value other than the one that
points to the syscall. What value of the program counter does control
usually return to? Why is this done?
Question 5 (4 points total)
Part A (2 points)
Why does the IEEE Floating Point standard specify more than one rounding
method?
Part B (2 points)
What is the result of +infinity - +infinity? Why?
Question 6 (6 points total)
You are a computer designer, and you are considering the
cache design on a computer system.
For purposes of comparison,
you use as your sample code the optimized code considered on
the homework.
A 1024 by 1024 array (called Bucky) of single precision floating point numbers
are stored in row major order.
The code sums all elements of the array and
re-initializes each element to the value 0.0.
rsum = 0.0
do ri = 1 to 1024 {
do rj = 1 to 1024 {
rsum = rsum + Bucky[ri,rj]
Bucky[ri,rj] = 0.0
}
}
The cache currently holds 512 bytes of data, and each block is 32 bytes.
Question 7 (9 points)
Part A (3 points)
Identify every data dependency (read-after-write, write-after-read,
write-after-write) involving $14 in the following code
fragment. For each dependency, circle register operands that
begin and end the dependence, draw an arrow from the first
operand to the second (e.g., from the register read to register
written on a read-after-write dependence), and label the arrow
as RAW, WAR, or WAW. Be sure to note that the loop may execute
more than once.
addi $13, $0, 1 # i = 1
add $12, $0, $0 # sum = 0
addi $15, $0, 100 # max = 100
loop: mult $13, $13 # i*i
mflo $14
add $15, $12, $14 # tmp = sum + i*i
add $12, $15, $0 # sum = tmp
addi $13, $13, 1 # i = i + 1
bne $13, $15, loop
addi $13, $0, 1 # i = 1
add $12, $0, $0 # sum = 0
addi $15, $0, 100 # max = 100
loop: mult $13, $13 # i*i
mflo $14
add $15, $12, $14 # tmp = sum + i*i
add $12, $15, $0 # sum = tmp
addi $13, $13, 1 # i = i + 1
bne $13, $15, loop
addi $13, $0, 1 # i = 1
add $12, $0, $0 # sum = 0
addi $15, $0, 100 # max = 100
loop: mult $13, $13 # i*i
mflo $14
add $15, $12, $14 # tmp = sum + i*i
add $12, $15, $0 # sum = tmp
addi $13, $13, 1 # i = i + 1
bne $13, $15, loop