Last active
April 15, 2016 04:32
-
-
Save Marlysson/1fa54352c86b84d6a9da181b4d69003d to your computer and use it in GitHub Desktop.
Script para detecção de Deadlock
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
existentes = [5,4,2,2] | |
disponiveis = [3,3,2,1] | |
requisitados = [ | |
[2,0,3,1], | |
[3,1,4,2], | |
[0,0,0,0], | |
[1,2,1,1] | |
] | |
comparacao , soma = 0 | |
for i in range(len(disponiveis)): | |
soma = disponiveis[i] + (requisitados[0][i] + requisitados[1][i] + requisitados[2][i] + requisitados[3][i]) | |
if soma > existentes[i]: | |
comparacao += 1 | |
soma = 0 | |
if comparacao != 0: | |
print("Deadlock") | |
else: | |
print("Não Deadlock") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment