Skip to content

Instantly share code, notes, and snippets.

@lsartori94
Created May 5, 2017 02:16
Show Gist options
  • Save lsartori94/ed8247b02304fbe41bd400b1cb81c0d6 to your computer and use it in GitHub Desktop.
Save lsartori94/ed8247b02304fbe41bd400b1cb81c0d6 to your computer and use it in GitHub Desktop.
sem mutex = 1; int bolsas = 0;
process voluntario [0..4]
{
P(mutex) //espero a poder acceder a bolsa
while(bolsas < 1000)
{
bolsas++
V(mutex) //libero bolsa
lleno_bolsa()
P(mutex) //espero a que se libere bolsa para la vuelta del loop
}
V(mutex) //libero bolsa antes de irme para que el proximo pueda evaluar el loop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment