Consider the following program that monitors two sensors. Here sensorl and sensor2 denote the variables storing...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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? 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?
Expert Answer:
Answer rating: 100% (QA)
a No it is not possible for the ISR to update the value of sensorl while the main function is checki... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these accounting questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Consider the following program segment, where i, j, k, n, and counter are integer variables and the value of n (a positive integer) is set prior to this segment. counter : = 0 for i : = 1 to n do for...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
We look at the accumulated area beneath this curve, as in the definite integral as follows F(x) = f(t) dt -2 { F(x) = int_(-2)^x f(t) dt a) Use ordinary area formulas to compute each of the...
-
The three regions shown in Fig. 8-32 (P8.9) contain perfect dielectrics. For a wave in medium 1 incident normally upon the boundary at z = - d, what combination of r2 and d produce no...
-
Department indirect-cost rates are never activity-cost rates. Do you agree? Explain.
-
Explain each of the relationships outlined in the quadrants in Figure 10.1 (page 239). Detail the actions that would lead to a favourable change in direction in each of the four relationships...
-
Shen and Smith [Ind. Eng. Chem. Fundam., 7, 100-105 (1968)] measured equilibrium-adsorption isotherms at four different temperatures for pure benzene vapor on silica gel, having the following...
-
istered VAT vendor and buys and sells furniture. Africa Traders wants to sell a dining room table with a cost price of R 5 2 0 0 . The mark - up percentage on cost is 2 0 % . What will be the selling...
-
ACCT 110 Integrated Excel Assignment #2 - Instructor: Nicole Harris Part 1: Balance Sheet and Income Statement Instructions: Use the drop down list under the column "type of account" to categorize...
-
The goal of this assignment is to demonstrate that you can use aesthetic principles in your own reasoning, and to look at an object in a new, perhaps more open-minded, way. Ideally you should learn...
-
Research for this chapters Adaptive Selling Today Training Video revealed that anger does surface during the sales presentation and can be very challenging to negotiate. Anger can be something the...
-
You have been hired to design a sampling procedure for testing a new antiacne drug. One hundred people will be used in the study: half will receive the new drug, and half will receive the standard...
-
Using your search engine, examine the Internet for information on customer satisfaction. Type in customer satisfaction + selling. Are you surprised by the number of queries on this subject? Examine...
-
Mr. Clark has $100 and would like to try his luck in an Atlantic City casino. Suppose he is faced with a 60/40 chance of losing $20 or winning $15. Further suppose that for a fee of $10, he can buy...
-
Does the risk-averse decision maker ever take any risk?
-
Sylvia wants to buy a car and feels that she can afford payments of $230 per month (month-end payments) for five years. Using an interest rate of j 12 =4.8%, what is the most expensive car that she...
-
Solve each equation or inequality. |6x8-4 = 0
-
For each of the following cases, indicate the filing status for the taxpayer(s) for 2012 using the following legend: A - Single B - Married, filing a joint return C - Married, filing separate returns...
-
Bill and Guilda each own 50 percent of the stock of Radiata Corporation, an S corporation. Guilda's basis in her stock is $25,000. On July 31, 2012, Bill sells his stock, with a basis of $40,000, to...
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
Try-Hard Company was organized in early January of 19X7. The company is in the business of taking computer chips from discarded personal computers and making vases and other items that are used to...
-
How do auditors often determine their anticipated reliance on the internal control structure?
-
Prior to beginning the field work on a new audit engagement in which a CPA does not possess expertise in the industry in which the client operates, the CPA should a. Reduce audit risk by lowering the...
Study smarter with the SolutionInn App