subject

Consider the following program that monitors two sensors. Here sensor1 and sensor2 denote
the variables storing the readouts from two sensors. The actual read is performed by the
functions readSensor1() and readSensor2(), respectively, which are called in the interrupt
service routine ISR.

char flag = 0;
char* display;
short sensor1, sensor2;

void ISR() {
if (flag) {
sensor1 = readSensor1();
} else {
sensor2 = readSensor2();
}
}

int main() {

// ... set up interrupts ...
// ... enable interrupts ...
while(1) {
if (flag) {
if isFaulty2(sensor2) {
display = "Sensor2 Faulty";
}
} else {
if isFaulty1(sensor1) {
display = "Sensor1 Faulty";
}
}
flag = !flag;
}

}

Functions isFaulty1() and isFaulty2() check the sensor readings for any discrepancies,
returning 1 if there is a fault and 0 otherwise. Assume that the variable display defines what is
shown on the monitor to alert a human operator about faults. Also, you may assume that flag
is modified only in the body of main. Answer the following questions:
a) Is it possible for the ISR to update the value of sensor1 while the main function is
checking whether sensor1 is faulty? Why or why not?
b) Suppose a spurious error occurs that causes sensor1 or sensor2 to be a faulty value for
one measurement. Is it possible for that this code would not report "Sensor1 faulty" or
"Sensor2 faulty"?
c) Assuming the interrupt source for ISR() is timer-driven, what conditions would cause this
code to never check whether the sensors are faulty?

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 19:10, gummybear1398
Select the correct answer. emma, the quality control manager in a software development company, asks the testing team to check whether the user interface is friendly. to which type of testing is emma referring? a. usability testing b. data comparison c. validation testing d. stress testing e. destruction testing
Answers: 1
image
Computers and Technology, 22.06.2019 17:30, babyface1686
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, BobBball9126
How do you share someone else’s tweet with your own twitter followers?
Answers: 1
image
Computers and Technology, 25.06.2019 05:30, sherlock19
Radar devices are used by law enforcement to be sure that individuals are driving safely. they tell the officer how fast the vehicle is traveling at that specific moment in time. the radar device determines the vehicle's a. instantaneous speed. b. acceleration. c. maximum velocity. d. average speed.
Answers: 1
You know the right answer?
Consider the following program that monitors two sensors. Here sensor1 and sensor2 denote
the...

Questions in other subjects:

Konu
Mathematics, 07.11.2020 01:00
Konu
Biology, 07.11.2020 01:00
Konu
Biology, 07.11.2020 01:00
Konu
Biology, 07.11.2020 01:00