Last change
on this file since 10 was 2, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti
|
-
Property svn:executable
set to
*
|
File size:
641 bytes
|
Rev | Line | |
---|
[2] | 1 | SHARED_MEM=turno
|
---|
| 2 | echo pippo > $SHARED_MEM
|
---|
| 3 |
|
---|
| 4 | processo(){ # name other
|
---|
| 5 | for i in $(seq 100); do
|
---|
| 6 | enter_region $1 $2
|
---|
| 7 | critical_session $1
|
---|
| 8 | leave_region $1
|
---|
| 9 | io
|
---|
| 10 | done
|
---|
| 11 | }
|
---|
| 12 | critical_session(){
|
---|
| 13 | for i in 1 2 3; do
|
---|
| 14 | echo -n $1
|
---|
| 15 | io
|
---|
| 16 | done
|
---|
| 17 | echo .
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | io(){
|
---|
| 21 | dd if=/dev/zero of=/dev/null count=1000 2>/dev/null
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | enter_region() { # process other
|
---|
| 25 | echo "true" > interested_$1
|
---|
| 26 | echo $1 > $SHARED_MEM
|
---|
| 27 | while grep $1 $SHARED_MEM >/dev/null &&
|
---|
| 28 | grep true interested_$2 >/dev/null ;
|
---|
| 29 | do
|
---|
| 30 | true;
|
---|
| 31 | done
|
---|
| 32 | }
|
---|
| 33 | leave_region() { # process
|
---|
| 34 | echo "false" > interested_$1
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | processo pippo pluto & processo pluto pippo &
|
---|
| 38 | wait
|
---|
Note:
See
TracBrowser
for help on using the repository browser.