Docsity

ECE 3035 Fall 2004 Computing Mechanisms Final Exam, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 3035 A 10:00am Computing Mechanisms Fall 2004
5 problems, 8 pages Final Exam 6 December 2004
1
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have
a question, raise your hand and I will come to you. Please work the exam in pencil and do not
separate the pages of the exam. For maximum credit, show your work.
Good Luck!
Your Name (please print) ________________________________________________
1 2 3 4 5 total
32 48 30 24 18 152
pf3
pf4
pf5
pf8

Partial preview of the text

Download ECE 3035 Fall 2004 Computing Mechanisms Final Exam and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

5 problems, 8 pages Final Exam 6 December 2004

Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate the pages of the exam. For maximum credit, show your work. Good Luck!

Your Name ( please print ) ________________________________________________

1 2 3 4 5 total

5 problems, 8 pages Final Exam 6 December 2004

Problem 1 (5 parts, 32 points) Heap Management

Below is a snapshot of heap storage. The heap pointer is 6328, the free pointer is 6184.

addr value addr value addr value addr value addr value addr value 6000 4 6064 6012 6128 43 6192 6300 6256 25 6320 4 6004 6100 6068 2043 6132 23 6196 12 6260 2346 6324 0 6008 24 6072 3234 6136 6534 6200 2567 6264 6067 6328 0 6012 0 6076 49 6140 6200 6204 9214 6268 9048 6332 0 6016 1 6080 512 6144 7670 6208 555 6272 39 6336 0 6020 2 6084 6068 6148 16 6212 16 6276 4 6340 0 6024 3 6088 7069 6152 6116 6216 6108 6280 6324 6344 0 6028 4 6092 8484 6156 5500 6220 3254 6284 8 6348 0 6032 5 6096 4 6160 1256 6224 6600 6288 4 6352 0 6036 20 6100 6152 6164 2525 6228 234 6292 8 6356 0 6040 6142 6104 4 6168 8 6232 40 6296 20 6360 0 6044 2336 6108 6172 6172 6064 6236 6200 6300 4 6364 0 6048 6494 6112 32 6176 2323 6240 4501 6304 8 6368 0 6052 2321 6116 6280 6180 12 6244 2302 6308 12 6372 0 6056 7876 6120 2312 6184 6004 6248 6723 6312 16 6376 0 6060 32 6124 9000 6188 6100 6252 7684 6316 20 6380 0

Part A (8 points) Assuming the heap has been allocated contiguously beginning at 6000, with no gaps between objects, circle all object size words in the map above.

Part B (6 points) How many heap objects are on the free list?

Part C (5 points) If the next instruction is alloc(25), what address will be returned?

Part D (5 points) If the next instruction is alloc(36), what address will be returned?

Part E (8 points) If the next instruction is free(ptr) where ptr = 6012, what changes to storage will result?

5 problems, 8 pages Final Exam 6 December 2004

Part D (16 points) In many implementations of DarkMaze, it is valuable to have a visit array that keeps track of which cells have been visited. A 16 x 16 maze has 256 cells and each cell requires a single bit to indicate whether the cell has been visited (assume 0 = unvisited, 1 = visited). These 256 bits can be represented by eight 32-bit words in memory. Write the MIPS code fragment MarkVisit below that translates a packed position in $1 (bits 3-0 represent X, bits 7- 4 represent Y) into one of eight memory addresses and then set the bit marking the array as visited. The visit array should then be updated. The modified memory location may already contain marked bits for other cells; these bits should not be changed. Assume the memory reservation listed below. Use any registers needed to perform this task.

label instruction comment Visit .word 0,0,0,0,0,0,0,0 # reserve & init visit array

instruction # visited position placed in $

MarkVisit:

5 problems, 8 pages Final Exam 6 December 2004

Problem 3 (3 parts, 30 points) Stacks

Consider the recursive factorial program below. Suppose it is called with an input value of 5 using the jal at memory address 2000. $29 = 9100 immediately before Fact is called at 2000. Answer the following questions below about the state of the machine immediately following completion of the recursive factorial execution when “next instruction” begins.

1000 Fact: addi $02, $00, 1 1004 slti $03, $01, 2 1008 bne $03, $00, Skip 1012 addi $29, $29, - 1016 sw $31, 4($29) 1020 sw $01, 0($29) 1024 addi $01, $01, - 1028 jal Fact 1032 lw $01, 0($29) 1036 lw $31, 4($29) 1040 addi $29, $29, 8 1044 mult $01, $ 1048 mflo $ 1052 Skip: jr $

2000 jal Fact 2004 next instruction Part A (10 points) What are the contents of the following registers:

$1: $2: $3: $29: $31:

Part B (10 Points) What is the contents of the stack when the instruction at 2004 begins?

9100 9096 9092 9088 9084 9080 9076 9072 9068 9064 9060

Part C (10 Points) When Fact is called with input = 5, how many instructions are executed. Do not count the jal at 2000 or the “next instruction”. Show work.

Number of instruction executed (dynamic I) =

5 problems, 8 pages Final Exam 6 December 2004

Part C (8 points) Is this string ambiguous? if (x > y) if (j < k) q = x / y; else q = x + y; YES / NO (circle one)

Show parse tree(s) for this expression. If there is more than one, circle the one that corresponds to the correct interpretation according to C language rules.

5 problems, 8 pages Final Exam 6 December 2004

Problem 5 (3 parts, 18 points) Short Answer

Part A (6 points) An interference graph is used in the code generation process. Each node represents a variable’s live range. What do the edges (arcs between the nodes) represent?

Part B (6 points) Most preemptive multitasking operating systems schedule tasks in terms of a fixed time interval or slot. Explain the risks of making the slot too big and too small.

If the slot is too big:

If the slot is too small:

Part C (6 points) List three benefits of virtual memory in computing systems.