📄 file.h
字号:
#include "banker.h"#include "res.h"list< list<int> > g_thread;//进程队列list<string> g_thread_name;//进程名称vector<int> needed_tmp;//需要分配资源临时队列void add_res(int x){ if (x < g_res_size) (*(needed_tmp.begin()+ x))++; //else // cout << "ERROR:resource " << x << "can not be found" << endl;}//将文件读入内存,并读取文件的资源申请void add_thread(char* filename){ ifstream file(filename); if (!file.is_open()) cout << "ERROR:command "<< filename <<" not found" << endl; else { char ch; int x; needed_tmp = empty; list <int> thread_text;//进程内容 while (!file.eof()) { file >> ch; if (ch == '#' && !file.eof()) { file >> ch; file.putback(ch); if (ch <= '9' && ch >= '0') { file >> x; add_res(x); thread_text.push_back( (int)'#' ); thread_text.push_back(x);//把x放入进程队列 } } else if(ch == '*' && !file.eof()) { file >> ch; file.putback(ch); if (ch <= '9' && ch >= '0') { file >> x; add_res(x); thread_text.push_back( (int)'*' ); thread_text.push_back(x);//把x放入进程队列 } } else thread_text.push_back( (int)ch ); } //把需求队列放入需求矩阵,并且把已分配队列置空后放入已分配矩阵 add_thread_res(needed_tmp); //把文件指针关闭 file.close(); g_thread.push_back(thread_text); //把文件(进程)名称放入队列 g_thread_name.push_back(filename); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -