source: trunk/alternanza.sh @ 2

Last change on this file since 2 was 2, checked in by Mattia Monga, 9 years ago

Importazione sorgenti

File size: 489 bytes
Line 
1SHARED_MEM=turn
2echo pippo > $SHARED_MEM
3
4processo(){ # 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}
16critical_session(){ 
17  for i in 1 2 3; do
18      echo -n $1
19      io
20  done
21  echo .
22}
23
24io(){
25 dd if=/dev/zero of=/dev/null count=1000 2>/dev/null
26}
27
28processo pippo & processo pluto &
29wait
Note: See TracBrowser for help on using the repository browser.