This commit is contained in:
Francesco Mecca 2018-11-26 10:34:53 +01:00
parent ecde016aab
commit 4ec7733b98
12 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,52 @@
int maxA,maxR;
int A=0,R=1;
process contenitore {
port int inizio_vers[2];
port signal fine_vers;
port signal inizio_estr;
port signal fine_estr;
process v, e;
signal s;
int qA,qR;
int va = 0;
do
qA+1<maxA; v=receive from inizio_vers[A] ->
qA++;
va++;
send(s) to v.ok;
qR+1<maxR; v=receive from inizio_vers[R] ->
qR++;
va++;
send(s) to v.ok;
receive(s) from fine_vers ->
va --;
va==0 && qA==2*qR && qA+qR>=C; e=receive(s) from inizio_estr ->
send(s) to e.ok;
receive(s) from fine_estr
qA = qA - 2/3*C;
qR = qR - 1/3*C;
od
}
process versatore(X) {
signal s;
port ok;
while(true){
send(X) to contenitore.inizio_vers[X];
receive(s) from ok;
<versa>
send(s) to contenitore.fine_vers;
}
}
process estrattore() {
signal s;
port ok;
while(true) {
send(s) to contenitore.inizio_estr;
receive(s) from ok;
<estrai>
send(s) to contenitore.fine_estr;
}
}