UniTO/anno2/Sem1/Galla/MCAD/gdrive/Esercitazioni/Caffè/caffe-async (Copia in conflitto di Mattia Po 2014-10-10).txt
Francesco Mecca 015f8ad739 scpd no git
2019-05-20 20:33:58 +02:00

52 lines
924 B
Text

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;
}
}