
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Embedded Microcomputer Systems; Subject: (Electrical and Comp Engr); University: University of Houston; Term: Unknown 1989;
Typology: Exams
1 / 1
This page cannot be seen from the preview
Don't miss anything!

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.