216k views
5 votes
If we can lock a file, we can solve the race condition problem by locking a file during the check-and-use window, because no other process can use the file during the time window. Why don’t we use this approach to solve the race condition problems discussed in this chapter?

User Monowerker
by
7.0k points

1 Answer

5 votes

Answer:

A file can only be locked out to other users or processes only if it's already open, meaning it's in use as a resource during the time window and therefore it's impossible solving the race condition problem by locking the file during the check-and-use window.

Hence, during the check-and-use process, it's impossible to lock a file.

In conclusion, any lock created can be ignored by the malicious process.

User Gaurav Saraswat
by
6.8k points