The test-and-set instruction is a very important CPU instruction for achieving atomic locks.
Is there a similar operation for the filesystem on linux/mac/windows?
Use case: A database program might be storing data in files. This instruction would be useful to ensure no changes occur to a file by another process while an operation is in progress.