
# process A: lock the file and subtract 20įlock -verbose balance.dat. We create a simple shell script a.sh to simulate process A: #!/bin/bash #sleep 10 seconds to simulate business calculationĮcho -n -e "\033[77DCalculating new balance.$progress%"Įcho "Write new balance ($value) back to $file."
#Linux file system reader and writer windows 10 update#
We first create a simple shell script update_balance.sh to handle balance update logic for both processes: #!/bin/bash In this example row, the entire file is locked.


Let’s pick the first row to understand how the lock information is organized in the /proc/locks file system: 1: FLOCK ADVISORY WRITE 369159 08:12:22417368 0 EOF

The lslocks command relies on this file to generate the list, too. Instead, it is a file in the procfs virtual file system.
