Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Study the following software example which shows data sharing between an ISR and the background main task. 1) Is this software prone to data corruption

Study the following software example which shows data sharing between an ISR and the background main task.

1) Is this software prone to data corruption due to a shared data bug?

2) If yes, explain the problem using an example.

3) How would you resolve this?

static int iMinutes, iSeconds; //global variables

Void main (void) {

int TotalSeconds;

iSeconds = 0;

iMinutes = 0;

while(TRUE)

{

TotalSeconds = (iMinutes * 60) + iSeconds;

!! Print TotalSeconds onto serial port.

} }

void interrupt vTimeUpdate(void) //Timer ISR which runs every one second {

!! ISR book keeping, clearing flag, scheduling next interrupt, etc.

iSeconds++;

if (iSeconds>59)

{ iSeconds = 0;

iMinutes++;

}

}

image text in transcribed

static int iMinutes, iSeconds; Iglobal variables Void main (void) int TotalSeconds; iSeconds 0 iMinutes-0 while(TRUE) TotalSeconds (iMinutes 60)+iSeconds !! Print TotalSeconds onto serial port. void interrupt vTimeUpdate(void) /Timer ISR which runs every one second !! ISR book keeping, clearing flag, scheduling next interrupt, etc iSeconds++; if (iSeconds>59) [iSeconds 0: iMinutes++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago