www.pudn.com > banker666.rar > 1.cpp


#include 
#include 
#include 
#include "windows.h" 
#define MAX_PROCESS 32             //最大进程数 
#define MAX_COURCE 64              //最大资源类别 
 
int MAX_FACT_PROCESS;              //实际总进程数 
int MAX_FACT_COURCE;               //实际资源类别数 
int Available[MAX_COURCE];                 //可利用资源向量 
int Max[MAX_PROCESS][MAX_COURCE];          //最大需求矩阵 
int Allocation[MAX_PROCESS][MAX_COURCE];   //分配矩阵 
int Need[MAX_PROCESS][MAX_COURCE];         //需求矩阵 
 
int Request_PROCESS;                       //发出请求的进程 
int Request_COURCE;                        //被请求资源类别 
int Request_COURCE_NEMBER;                 //请求资源数 
 
struct COMP{ 
	int value; 
	int num; 
	int next; 
}; 
int flag=0; 
void Read_Initiate(void){ 
	ifstream infile("Initiate.txt"); 
	    if(!infile){ 
		cout<<"不能打开输入文件:"<<"Initiate.txt"<<'\n'; 
		exit(1); 
	} 
	cout<<"开始读入初始化文档"<<'\n'; 
	int ch; 
	int Array[MAX_PROCESS*MAX_COURCE*2]; 
	int num=0; 
	while(infile>>ch) 
	     Array[num++]=ch; 
	num=0; 
    MAX_FACT_COURCE=Array[num++]; 
    for(int j=0;j>ch) 
		Array[num++]=ch; 
	num=0; 
		for(int i=0;i>ch) 
	     Array[num++]=ch; 
    Request_PROCESS=Array[0]; 
    Request_COURCE=Array[1]; 
    Request_COURCE_NEMBER=Array[2]; 
	infile.close(); 
} 
 
void Write_Allocation(void){ 
	ofstream outfile("Allocated_list.txt"); 
	if(!outfile){ 
		cout<<"不能打开资源分配列表:"<<'\n'; 
		exit(1); 
	} 
	for(int i=0;i=Array[j].value){ 
				int t; 
				t=Array[j].value; 
                Array[j].value=Array[i].value; 
				Array[i].value=t; 
				t=Array[j].num; 
                Array[j].num=Array[i].num; 
                Array[i].num=t; 
			} 
			else continue; 
		} 
	DWORD m_delay=3000; 
	Sleep(m_delay); 
/*	for(i=0;i"; 
    for(i=0;i"; 
	} 
	cout<<'\n'<<"已通过安全性测试!"<>flag; 
	if(flag==2) 
		exit(0); 
	if(flag==1) 
	{ 
	cout<<"开始扫描请求信息!"<Need[Request_PROCESS-1][Request_COURCE-1]) 
	{ 
		cout<<'\n'<<"第"<Available[Request_COURCE-1]) 
	{ 
		cout<<'\n'<<"第"<