Question: Consider the following program that monitors two sensors. Here sensorl and sensor2 denote the variables storing the readouts from two sensors. The actual read

Consider the following program that monitors two sensors. Here sensorl and sensor2

Consider the following program that monitors two sensors. Here sensorl and sensor2 denote the variables storing the readouts from two sensors. The actual read is performed by the functions readSensorl() and readSensor2(), respectively, which are called in the interrupt service routine ISR. char flag = 0; char display; short sensorl, sensor2; void ISR () { } if (flag) { } } else { } sensorl = readSensorl(); int main() { sensor2 = readSensor2 (); } set up interrupts // ... enable interrupts while (1) { if (flag) { if is Faulty2 (sensor2) { display = "Sensor2 Faulty"; } } else { if is Faultyl (sensorl) { } display = "Sensorl Faulty"; flag = !flag; Functions is Faulty10) and isFaulty20) 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 sensorl is faulty? Why or why not? b) Is it possible for the ISR to update the value of sensor2 while the main function is checking whether sensor2 is faulty? Why or why not? c) Suppose a spurious error occurs that causes sensorl or sensor2 to be faulty for one measurement. Is it possible that this code would not report "Sensorl faulty" or "Sensor2 faulty"? Please explain your answer. d) Assuming the interrupt source for ISR() is timer-driven, what conditions would cause this code to never check whether the sensors are faulty?

Step by Step Solution

3.52 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a No it is not possible for the ISR to update the value of sensorl while the main function is checki... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!

Q:

\f