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: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 20:00
Me ajude por favor , coloquei uma senha e nรฃo consigo tira-la no chorme
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
Apart from confidential information, what other information does nda to outline? ndas not only outline confidential information, but they also enable you to outline .
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
Lucas put a lot of thought into the design for his company's new white paper. he made sure to include repeating design elements such as color schemes and decorative images. his goal was to a.add symmetry b.create a unified publication c.provide consistency d.save money
Answers: 1
question
Computers and Technology, 24.06.2019 02:20
The first time a user launches the powerpoint program, which view is shown allowing the user to access recent presentations or create new presentations based on templates?
Answers: 1
You know the right answer?
Consider the following program that monitors two sensors. Here sensor1 and sensor2 denote
the...
Questions
Questions on the website: 13722361