source: trunk/alea.sh @ 2

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

Importazione sorgenti

  • Property svn:executable set to *
File size: 420 bytes
Line 
1SHARED_MEM=lock
2echo 0 > $SHARED_MEM
3
4processo(){ # name
5 for i in $(seq 1000); do
6     while grep 1 $SHARED_MEM >/dev/null ; do true; done
7     echo 1 > $SHARED_MEM
8     critical_session $1
9     echo 0 > $SHARED_MEM
10     io
11 done
12}
13critical_session(){ 
14  for i in 1 2 3; do
15      echo -n $1
16      io
17  done
18  echo .
19}
20
21io(){
22 dd if=/dev/zero of=/dev/null count=1000 2>/dev/null
23}
24
25processo pippo & processo pluto &
26wait
Note: See TracBrowser for help on using the repository browser.