Portál AbcLinuxu, 7. prosince 2025 22:01
mkfifo /moje/dlouha/roura echo > /moje/dlouha/roura &pokus o kritickou sekci:
head -1 /moje/dlouha/roura ..práce nad sdílenou pamětí.. echo > /moje/dlouha/roura &prostě proces může vstoupit do kr. sekce jen tehdy, pokud může načíst řádek z roury = nikdo jiný v kritické sekci není (jinak je uspán) je tam někde chyba nebo by to tak fakt mohlo fungovat?
lockfile(1)
Suppose you want to make sure that access to the file
"important" is serialised, i.e., no more than one program
or shell script should be allowed to access it. For sim-
plicity's sake, let's suppose that it is a shell script.
In this case you could solve it like this:
...
lockfile important.lock
...
access_"important"_to_your_hearts_content
...
rm -f important.lock
...
Now if all the scripts that access "important" follow this
guideline, you will be assured that at most one script
will be executing between the `lockfile' and the `rm' com-
mands.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.