1 Star 1 Fork 0

仓葵与暮/os-project-2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sprocess.cpp 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
仓葵与暮 提交于 2021-09-17 19:54 . 初始化
#include "sprocess.h"
/*
* Constuctors
*/
int SProcess::getMemoryNeed() const
{
return memoryNeed;
}
void SProcess::setMemoryNeed(int value)
{
memoryNeed = value;
}
SProcess::SProcess(){
pname = "";
runTime = 0;
priority = 0;
memoryNeed = 0;
pstatus = BACKUP;
pcb = new SPCB(pname,runTime,priority,memoryNeed);
}
SProcess::SProcess(QString pname, int runTime, int priority, int memoryNeed)
{
this->pname = pname;
this->runTime = runTime;
this->priority = priority;
this->memoryNeed = memoryNeed;
pstatus = BACKUP;
pcb = new SPCB(pname,runTime,priority,memoryNeed);
}
SProcess::~SProcess(){
if(pcb!=nullptr) delete pcb;
}
/*
* Getters and Setters
*/
void SProcess::setPname(const QString &value)
{
pname = value;
}
void SProcess::setRunTime(int runtime){
runTime = runtime;
}
void SProcess::setPriority(int prt){
priority = prt;
}
void SProcess::setPstatus(STATUS status){
pstatus = status;
}
void SProcess::setPCB(QString pname, int runtime, int priority, STATUS status, int memoryNeed){
if(pcb!=nullptr){
pcb->setPname(pname);
pcb->setPriority(priority);
pcb->setRuntime(runtime);
pcb->setStatus(status);
pcb->setMemoryNeed(memoryNeed);
}
else{
qDebug()<<"pcb pointer is null error in setPCB";
}
}
/**
* @brief SProcess::setDefaultPCB
* 设置默认的PCB值
*/
void SProcess::setDefaultPCB()
{
if(pcb!=nullptr){
pcb->setPname(pname);
pcb->setPriority(priority);
pcb->setRuntime(runTime);
pcb->setStatus(pstatus);
pcb->setMemoryNeed(memoryNeed);
pcb->setMemoryBegin(0);
pcb->setColorOrder(0);
}
else{
qDebug()<<"pcb pointer is null error in setDefaultPCB";
}
}
QString SProcess::getPname() const{
return pname;
}
int SProcess::getRunTime() const{
return runTime;
}
int SProcess::getPriority() const{
return priority;
}
STATUS SProcess::getPstatus() const{
return pstatus;
}
SPCB *SProcess::getPCB() const{
if(pcb!=nullptr){
return pcb;
}
else{
qDebug()<<"pcb pointer is null error";
}
}
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

搜索帮助