⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcb.cpp

📁 链表实现的银行家算法
💻 CPP
字号:
#include "stdafx.h"
#include "PCB.h"
#include <iostream.h>
PCB::PCB()
{
	resLen = 0;
	name = new char[80];
	Max = 0;
	Alloc = 0;
	Need = 0;
	nextPCB = 0;
	prePCB = 0;
}
PCB::~PCB()
{
	delete name, Max, Alloc, Need;
}
void PCB::InitPCB()
{
	Max = new int[resLen];
	Alloc = new int[resLen];
	Need = new int[resLen];
}
void PCB::InitPCB(int *max)
{
	for(int i = 0; i < resLen; i++)
	{
		Max[i] = max[i];
		Alloc[i] = 0;
		Need[i] = max[i];
	}
}
void PCB::Run(int *remain, int *req)
{
	for(int i = 0; i < resLen; i++)
	{
		Alloc[i] += req[i];
		remain[i] -= req[i];
		Need[i] -= req[i];
	}
}
void PCB::Resever(int *remain, int *req)
{
	for(int i = 0; i < resLen; i++)
	{
		Alloc[i] -= req[i];
		remain[i] += req[i];
		Need[i] += req[i];
	}
}






















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -