while(!s.hold)appear in the V() operation?
#!/bin/sh
# Fill a file with monotonically increasing integers.
# Demonstrates use of 'ln' and 'rm' to implement critical sections.
# Usage: file-append.sh &; file-append.sh
# John Noll Monday, March 07 2005
# Create the lock file.
[ -f file.lock ] || touch file.lock
# Create a repository to hold numbers.
[ -f numbers ] || echo 0 > numbers
# Loop, reading last number from the repository, increment it,
# then append next number to the repository.
i=0
while [ $i -lt 1000 ] ; do
# Enter critical section.
while [ true ] ; do
ln file.lock lock
[ $? -eq 0 ] && break
done
num=`tail -1 numbers`
num=`expr $num + 1`
echo $num >> numbers
# Leave critical section.
rm lock
i=`expr $i + 1`
done
echo "$$ Done"
% file-append.sh & file-append.shdoes this script work correctly? Why or why not?
Generated Thu Apr 3 12:23:18 2008