Last change
on this file since 12 was 2, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti
|
-
Property svn:executable
set to
*
|
File size:
420 bytes
|
Line | |
---|
1 | SHARED_MEM=lock
|
---|
2 | echo 0 > $SHARED_MEM
|
---|
3 |
|
---|
4 | processo(){ # 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 | }
|
---|
13 | critical_session(){
|
---|
14 | for i in 1 2 3; do
|
---|
15 | echo -n $1
|
---|
16 | io
|
---|
17 | done
|
---|
18 | echo .
|
---|
19 | }
|
---|
20 |
|
---|
21 | io(){
|
---|
22 | dd if=/dev/zero of=/dev/null count=1000 2>/dev/null
|
---|
23 | }
|
---|
24 |
|
---|
25 | processo pippo & processo pluto &
|
---|
26 | wait
|
---|
Note:
See
TracBrowser
for help on using the repository browser.