Question: Prob # 5 7 in book: Write a shell script in C + + that produces a file of sequential numbers by reading the last
Prob # in book:
Write a shell script in C that produces a file of sequential numbers by reading the last number in the file, adding to it and then appending it
to the file. Run one instance of the script in the background and one in the foreground, each accessing the same file.Hint: run a
command ending in a & to run in the background Assume integer numbers.
How long does it take before a race condition manifests itself? What is the critical region? Modify the script to prevent the ace.
Hint: use
In file file.lock
to lock the data file. Or you can use the official way "flock".
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
