Skip to content

Instantly share code, notes, and snippets.

@mgiagante mgiagante/semaphores_2.txt
Last active Sep 27, 2017

Embed
What would you like to do?
Semaphores 2
queue resource_queue[5] = [r1, r2, r3, r4, r5]
sem resources = 5
sem queue_mutex = 1
process Consumer {
p(resources)
p(queue_mutex)
resource my_resource = pop(resource_queue)
v(queue_mutex)
delay # Usa el recurso
p(queue_mutex)
push(resource_queue, my_resource)
v(queue_mutex)
v(resources)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.