死锁检测算法

时间:2015-09-26 03:17:50
【文件属性】:

文件名称:死锁检测算法

文件大小:1KB

文件格式:TXT

更新时间:2015-09-26 03:17:50

死锁检测递归

#include using namespace std; const int M = 3; const int N = 5; int Ava[M] = {3, 3, 2}; int All[N][M] = {{0,1,0},{2,0,0},{3,0,2},{2,1,1},{0,0,2}}; int Nee[N][M] = {{7,4,3},{1,2,2},{6,0,0},{0,1,1},{4,3,1}}; int work[N+1][M] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; int flag[N][2] = {{0,0},{0,0},{0,0},{0,0},{0,0}}; int count = 0; void Safe(int num); int main() { int num = 0; for (int k = 0; k < M; ++k) { work[num][k] = Ava[k]; } Safe(num); cout << "total: " << count; system("pause"); return 0; } void Safe(int num) { if (num == N) { count++; for (int m = 0; m < N; ++m) { cout << flag[m][1] << " "; } cout << endl; }


网友评论

  • 代码很有用,能够运行学习了!
  • 还行吧,谢谢
  • 还凑合吧。
  • 代码齐全,很有用!