1 Star 1 Fork 0

仓葵与暮/os-project-2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
spcb.cpp 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
仓葵与暮 提交于 2021-09-17 19:54 . 初始化
#include "spcb.h"
#define random(a,b) (rand() % (b-a+1))+a
/*
* Getters and Setters
*/
int SPCB::getRuntime() const
{
return runtime;
}
void SPCB::setRuntime(int value)
{
runtime = value;
}
void SPCB::delRuntime(int value)
{
if(runtime>0)
runtime -= value;
else
return;
}
QString SPCB::getPID() const
{
return PID;
}
void SPCB::setPID(int value)
{
PID = "P"+QString::number(value,10);
qDebug()<<PID;
}
QString SPCB::getPname() const
{
return pname;
}
void SPCB::setPname(const QString &value)
{
pname = value;
}
STATUS SPCB::getStatus() const
{
return status;
}
void SPCB::setStatus(STATUS value)
{
status = value;
}
int SPCB::getPriority() const
{
return priority;
}
void SPCB::setPriority(int value)
{
priority = value;
}
void SPCB::delPriority(int value)
{
if(priority>0){
priority -= value;
}
else
return;
}
void SPCB::addPriority(int value)
{
priority += value;
}
void SPCB::setNext(SPCB *value)
{
next = value;
}
/**
* Constructor
* @brief SPCB::SPCB
* @param pname
* @param priority
* @param runtime
*/
int SPCB::getMemoryNeed() const
{
return memoryNeed;
}
void SPCB::setMemoryNeed(int value)
{
memoryNeed = value;
}
int SPCB::getMemoryBegin() const
{
return memoryBegin;
}
void SPCB::setMemoryBegin(int value)
{
memoryBegin = value;
}
int SPCB::getColorOrder() const
{
return colorOrder;
}
void SPCB::setColorOrder(int value)
{
colorOrder = value;
}
void SPCB::refreshColor()
{
colorOrder = 1;
}
SPCB::SPCB(QString pname, int priority, int runtime, int memoryNeed)
{
// srand(( (int)time(NULL) )%100);
// PID = "P"+QString::number(random(1000,9999),10);
PID = "";
this->pname = pname;
this->priority = priority;
this->runtime = runtime;
//起初新建六个pcb,以状态值代表是否分配PCB,BACKUP表示未成为进程,无PCB
status = BACKUP;
next = nullptr;
this->memoryNeed = memoryNeed;
memoryBegin = 0;
colorOrder = 0;
// qDebug()<<PID;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/fortherepublic-cpp/os-project-2.git
git@gitee.com:fortherepublic-cpp/os-project-2.git
fortherepublic-cpp
os-project-2
os-project-2
master

搜索帮助