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.
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.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7b988f00-1430-4dac-806c-b0e1ca658c29%2Fedbdef65-489d-4564-a6de-6405aefec3a4%2Frge4yq8_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,