Given an application program where it shares a variable X for its tasks' execution, one of the program tasks calls Add method to add value to the variable X. Before the new value of X is saved, another task of the program calls Subtract method to subtract value from the shared variable X. This can cause race condition and arrive incorrect value of the shared variable X. Discover and explain what can be added to this application program in order to prevent race condition from occurring.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question
Given an application program where it shares a variable X for its tasks' execution, one of the
program tasks calls Add method to add value to the variable X. Before the new value of X is
saved, another task of the program calls Subtract method to subtract value from the shared
variable X. This can cause race condition and arrive incorrect value of the shared variable X.
Discover and explain what can be added to this application program in order to prevent race
condition from occurring.
Transcribed Image Text:Given an application program where it shares a variable X for its tasks' execution, one of the program tasks calls Add method to add value to the variable X. Before the new value of X is saved, another task of the program calls Subtract method to subtract value from the shared variable X. This can cause race condition and arrive incorrect value of the shared variable X. Discover and explain what can be added to this application program in order to prevent race condition from occurring.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computing Algorithms
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,