Please Turn OFF your ad blocker

- OR -

LOGIN to continue using GeekInterview website.

This site uses cookies to deliver our services and to show you relevant ads and job listings. By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Your use of GeekInterviewâ€™s Content, Products and Services, including the Exforsys Inc Network, is subject to these policies and terms.

## Data Inconsistency / Critical Section

Case 1:

"Processor #1 "for (a = 1; a <= 3; a++)

x = x + 1;

"Processor #2"

for (b = 1; b <= 3; b++)

x = x + 1;

Case 2:

"Processor #1"x = 0; x = 0;

for (a = 1; a <= 3; a++)

x = x + 1;

"Processor #2"

for (b = 1; b <= 3; b++)

x = x + 1;

a. If the processes P1 and P2 execute only once at any speed, what are the possible resulting values of x in Case 1 and Case 2? Explain your answers.

b. Suggest some modifications on the original code to eliminate the problem. (Answer part (b) only if you have identified data inconsistency / critical section problems in part (a))

fatema sawanProfile Answers by fatema sawan Questions by fatema sawan

Questions by fatema sawan

## Related Answered Questions

## Related Open Questions