Exam 1 with Solution - Embedded Microcomputer Systems | ECE 4437, Exams of Electrical and Electronics Engineering

Material Type: Exam; Class: Embedded Microcomputer Systems; Subject: (Electrical and Comp Engr); University: University of Houston; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 08/19/2009

koofers-user-hom
koofers-user-hom 🇺🇸

3

(1)

8 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2 (a). (10) You be the teacher. Write some code for the subroutine double() below that is an example
of a critical section that is not thread-safe. The global shared data is temp. Write the subroutine in
assembly language, assuming that the argument is passed to it in the A register, and it returns the result
in the B register.
main() {
y = double(10);
}
interrupt 16 isr() {
z = double(25);
}
; Subroutine double
; Returns double the value of the argument
; On entry, A = argument passed to subroutine
; On return, B = result
; Write this subroutine in a way such that it uses temp
; and illustrates a critical section.
temp DS.B 1;
double:
rts
(b). (10) For your example code, what incorrect result would main receive if main’s call to double()
was interrupted at the wrong time by isr’s call to double()? Mark with an arrow where in the code
you are saying this unfortunately-timed interrupt takes place.

Partial preview of the text

Download Exam 1 with Solution - Embedded Microcomputer Systems | ECE 4437 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

2 (a). (10) You be the teacher. Write some code for the subroutine double() below that is an example of a critical section that is not thread-safe. The global shared data is temp. Write the subroutine in assembly language , assuming that the argument is passed to it in the A register, and it returns the result in the B register.

main() { … y = double(10); … }

interrupt 16 isr() { … z = double(25); … }

; Subroutine double ; Returns double the value of the argument ; On entry, A = argument passed to subroutine ; On return, B = result ; Write this subroutine in a way such that it uses temp ; and illustrates a critical section.

temp DS.B 1; double:

rts

(b). (10) For your example code, what incorrect result would main receive if main’s call to double() was interrupted at the wrong time by isr’s call to double()? Mark with an arrow where in the code you are saying this unfortunately-timed interrupt takes place.