edited by
189 views
0 votes
0 votes
Write a shell script that produces a file of sequential numbers by reading the last number in the file, adding $1$ 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. How long does it take before a race condition manifests itself? What is the critical region? Modify the script to prevent the race.

(Hint: use ln file file.lock to lock the data file.)
edited by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
4