Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lsartori94/1cb65f84b81a2477d4e1992b19fcb2d3 to your computer and use it in GitHub Desktop.
Save lsartori94/1cb65f84b81a2477d4e1992b19fcb2d3 to your computer and use it in GitHub Desktop.
Cola int espera;
Sem cola = 1;
Sem maq_libre = 1;
Sem colaInv[0..9] = 0;
process investigador[0..99]
{
P(cola);
espera.push(i); //me pongo en espera
V(cola);
P(maq_libre); //si la maquina esta libre
P(cola);
V(colaInv[espera.pop()]); //dejo pasar al que sigue
V(cola);
P(colaInv[i]); // si soy el que sigue paso
usarMaquina();
V(maq_libre); //libero maquina
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment