Discussion
Two tasks each execute this on a shared counter, with no protection.
int t = count; t = t + 1; count = t;
Starting from zero, the final value may be
Answer: C
If either task completes all three lines before the other begins, the answer is two; if both read before either writes, one increment is lost and the answer is one. That the answer is not determinate is the whole meaning of a race.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development