Created
September 8, 2017 04:57
-
-
Save mgiagante/9ad1931a959a55ee60193e96b0ae9b10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sem free_detectors = 3 // Cantidad de detectores libres a cada instante | |
sem allocation = 1 // Limita la cantidad de personas que buscan ascensor al mismo tiempo | |
// Declara un arreglo de 0 a n-1 de booleans inicializados como false en todas sus posiciones. | |
// Representa los detectores valiendo para cada uno true si está ocupado o false si está libre. | |
boolean detector_taken[0:n-1] = ([n] false) | |
process Person[w = 1 to 100] { | |
p(free_detectors) | |
p(allocation) | |
int i = 0 | |
while detector_taken[i] { | |
i++ | |
} | |
detector_taken[i] = true // Ocupa el detector i | |
v(allocation) // Permite que otro busque un detector libre | |
delay // Usa el detector i | |
detector_taken[i] = false // Libera el detector i | |
v(free_detectors) // Aumenta la cantidad de detectores libres | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment