Last change
on this file since 12 was 2, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti
|
File size:
489 bytes
|
Line | |
---|
1 | SHARED_MEM=turn
|
---|
2 | echo pippo > $SHARED_MEM
|
---|
3 |
|
---|
4 | processo(){ # name
|
---|
5 | for i in $(seq 100); do
|
---|
6 | while grep -v $1 $SHARED_MEM >/dev/null ; do true; done
|
---|
7 | critical_session $1
|
---|
8 | if test "$1" = "pippo"; then
|
---|
9 | echo "pluto" > $SHARED_MEM;
|
---|
10 | else
|
---|
11 | echo "pippo" > $SHARED_MEM;
|
---|
12 | fi
|
---|
13 | io
|
---|
14 | done
|
---|
15 | }
|
---|
16 | critical_session(){
|
---|
17 | for i in 1 2 3; do
|
---|
18 | echo -n $1
|
---|
19 | io
|
---|
20 | done
|
---|
21 | echo .
|
---|
22 | }
|
---|
23 |
|
---|
24 | io(){
|
---|
25 | dd if=/dev/zero of=/dev/null count=1000 2>/dev/null
|
---|
26 | }
|
---|
27 |
|
---|
28 | processo pippo & processo pluto &
|
---|
29 | wait
|
---|
Note:
See
TracBrowser
for help on using the repository browser.