Question: 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++;

}

}

Study the following software example which shows data sharing between an ISR

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

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!