資源簡介
操作系統之--模擬銀行家算法實現死鎖避免
代碼片段和文件信息
#include
#include
#include
using?namespace?std;
#define?M?10?//最大進程數
#define?N?3?//系統所擁有的資源類型
int?Max[M][N];//進程對各類資源的最大需求
int?Allocation[M][N];//系統已為進程所分配的各類資源數
int?Need[M][N];//運行進程尚需的各類資源數
int?Work[N];//運行進程時系統所擁有的資源數
bool?finish[M];//表示系統是否有足夠的資源分配給進程
int??Available[N];//系統可利用的資源數
int?n_pro=0;//進程的數目
int?flag[M]={-1};//用于標記安全序列
int?Readfile();//從磁盤讀文件
int?Safe1(int?flag[]int?nint?t);//輸出所有安全狀態
void?show();
int?Safe();//判斷系統是否處于安全狀態
int?Request();//請求資源分配函數
void?show()
{
printf(“??\t%-9s\t%-9s\t%-9s\n““MAX““Allocation““Need“);
printf(“??\tA???B???C\tA???B???C\tA???B???C\n“);
for(int?i=0;i {
printf(“p%d\t%d%4d%4d\t“iMax[i][0]Max[i][1]Max[i][2]);
printf(“%d%4d%4d\t“Allocation[i][0]Allocation[i][1]Al
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????540731??2014-09-09?15:30??test\Debug\test.exe
?????文件?????741264??2014-09-09?15:30??test\Debug\test.ilk
?????文件?????284917??2014-09-09?15:30??test\Debug\test.obj
?????文件????2094456??2014-09-09?15:30??test\Debug\test.pch
?????文件????1065984??2014-09-09?15:30??test\Debug\test.pdb
?????文件??????74752??2014-09-09?15:30??test\Debug\vc60.idb
?????文件?????110592??2014-09-09?15:30??test\Debug\vc60.pdb
?????文件???????5191??2014-09-08?22:30??test\test.cpp
?????文件???????3377??2014-09-09?15:30??test\test.dsp
?????文件????????514??2014-09-09?15:35??test\test.dsw
?????文件??????41984??2014-09-09?15:35??test\test.ncb
?????文件??????48640??2014-09-09?15:35??test\test.opt
?????文件????????736??2014-09-09?15:30??test\test.plg
?????文件?????????81??2014-09-08?22:40??test\test.txt
?????目錄??????????0??2014-09-09?18:52??test\Debug
?????目錄??????????0??2014-09-09?18:52??test
-----------?---------??----------?-----??----
??????????????5013219????????????????????16
- 上一篇:LPC23XX IAP
- 下一篇:2.4寸TFT彩屏單片機驅動程序
評論
共有 條評論