pcb.cpp

来自「链表实现的银行家算法」· C++ 代码 · 共 73 行

CPP
73
字号
#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 + =
减小字号Ctrl + -
显示快捷键?