Docsity

Computing Mechanisms Final Exam Spring 2006, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 3035B 1:00pm Computing Mechanisms Spring 2006
5 problems, 9 pages Final Exam 3 May 2006
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
A
B
C
D total
E
20 34 28 24 40 146
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Computing Mechanisms Final Exam Spring 2006 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

5 problems, 9 pages Final Exam 3 May 2006

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 ) ________________________________________________

A

B

C

D total

E

5 problems, 9 pages Final Exam 3 May 2006

Problem 1 (1 part, 20 points) Iteration and Control Flow Graphs

Draw the control flow graph for the body of the following procedure.

int Foo (int S, int N, int Array[][N]) {

int I, J;

int Sum = 0;

for (I = 0; I < N; I++) {

J = I;

while (Array[I][J] != S) {

Sum += Array[I][J];

J++;}

return Sum;}

5 problems, 9 pages Final Exam 3 May 2006

Problem 3 (3 parts, 28 points) Activation Frames

Consider the following C fragment:

int Foo() { int Limit = 150; int StopIndex = 2; int Result = 0; Int Array[] = {20, 30, 101, 35, 80}; int Baz(int Limit, int *StopIndex, int Array[]);

Result = Baz(Limit, &StopIndex, Array); } int Baz(int Max, int *End, int Values[]) { int X, Sum = 0;

for (X = 0; X <= *End; X++) Sum += Values[X]; *End += 1; if (Sum > Max) return 1; else return 0; }

Part A (12 points) Describe the current state of the stack just before Baz returns. Fill in the unshaded

boxes to show Foo and Baz’s activation frames. Include a symbolic description and the actual value (in

decimal). Do not include values for return addresses. Label the frame pointer and stack pointer.

address description value

9900 RA of Foo’s caller

9896 FP of Foo’s caller

SP, Foo’s FP 9892 return value

5 problems, 9 pages Final Exam 3 May 2006

Part B (8 points) Given the state of the stack you computed in Part A, write a MIPS code

fragment to implement the statement from Baz: “Sum += Values[X];” Do not use absolute

addresses in your code; instead, access variables relative to the frame pointer.

instruction comment

Part C (8 points) Given the state of the stack you computed in Part A, write a MIPS code

fragment to implement the statement from Baz: “*End += 1;” Do not use absolute addresses in

your code; instead, access variables relative to the frame pointer.

instruction comment

5 problems, 9 pages Final Exam 3 May 2006

Problem 5 (5 parts, 40 points) Parsing and Short Answer

Consider the following grammar.

S Æ N flies A

S Æ Adj^ N^ like^ Obj

N Æ flies | time | banana | fruit | arrow

A Æ like D N

Obj Æ D N

D Æ a^ |^ an

Adj Æ fruit | red | small

Part A (10 points) Is this string ambiguous (i.e., has more than 1 parse tree)?

fruit flies like a banana YES / NO (circle one)

If it is not ambiguous, show its unique parse tree. If it is ambiguous, draw at least two parse trees.

Part B (10 points) Generate another string that is in the language of this grammar and show a parse tree

for it.

5 problems, 9 pages Final Exam 3 May 2006

Part C (8 points) Consider a multitasking system with four tasks T A, TB , TC , and TD. TA and TB

execute at equal priority. TC gets twice as much processor time as TA while TD gets a third of the

processor time of TA. What percentage of the processor time does TD receive? Ignore external

factors (page faults, interrupts, waits for I/O, etc.) Show work.

Part D (6 points) Explain three differences between the implementation of interrupt handling

and multitasking.

Part E (6 points) List three differences between the heap and stack allocated data storage.