?? shijianpian.h
字號(hào):
// RenBinOS.cpp : Defines the entry point for the console application.
//
// Test.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#include <vector>
#ifndef SHIJIANPIAN_H_
#define SHIJIANPIAN_H_
const int QOK=1;
const int QERROR=1;
const int QOVERFLOW=-1;
typedef int Status;
/*時(shí)間片輪轉(zhuǎn)算法*/
/* 進(jìn)程信息 */
typedef struct ElemType
{
char name[10];/*進(jìn)程名稱*/
int arriveTime;/*進(jìn)程到達(dá)時(shí)間*/
int cpuTime;/*進(jìn)程所需時(shí)間片數(shù)*/
int alreadyTime;/*進(jìn)程已運(yùn)行時(shí)間片數(shù)*/
int needTime;/*進(jìn)程完成仍需時(shí)間*/
char state; /*進(jìn)程狀態(tài):"R"運(yùn)行;"W"等待;"F"完成*/
ElemType( char* name2, int arrTime, int cpuTime2 )
{
memset( name, 0, 10 );
memcpy( name, name2, 10 );
arriveTime = arrTime;
cpuTime = cpuTime2;
needTime = cpuTime2;
state = 'W';
}
ElemType()
{
memset( name, 0, 10 );
arriveTime = 0;
cpuTime = 0;
alreadyTime = 0;
needTime = 0;
state = 'W';
}
ElemType& operator = ( const ElemType& elem )
{
memset( name, 0, 10 );
memcpy( name, elem.name, 10 );
arriveTime = elem.arriveTime;
cpuTime = elem.cpuTime;
alreadyTime = elem.alreadyTime;
needTime = elem.needTime;
state = elem.state;
return *this;
}
}ElemType;
/*結(jié)點(diǎn)類型*/
typedef struct PCB
{
ElemType data;
struct PCB *next;
}PCB,*PCBQueue;
/*鏈隊(duì)列類型*/
class LinkQueue {
public:
PCBQueue front; /*隊(duì)頭指針*/
PCBQueue rear; /*隊(duì)尾指針*/
private:
int totalTime; /* 運(yùn)行總時(shí)間 */
int curTime; /* 現(xiàn)在運(yùn)行時(shí)間 */
std::vector<ElemType> vecElem;
typedef std::vector<ElemType>::const_iterator QCIT;
ElemType lastElem;
bool bLastOver;
int nZhouzhuanTime;
////////////////////////////////////////////
public:
LinkQueue(); //初始化
~LinkQueue(); //銷毀
int GetLength() const; //隊(duì)列長度
int GetTotalTime() const; //隊(duì)列運(yùn)行總時(shí)間
bool IsEmpty() const; //隊(duì)列是否為空
ElemType GetLastRun(){ return lastElem; } // 上次運(yùn)行進(jìn)程
void SetElemVec( const std::vector<ElemType>& vec ); //加入要運(yùn)行的進(jìn)程
Status EnQueue( ElemType elem ); //入隊(duì)列
Status DeQueue( ElemType& elem ); //刪對(duì)頭
Status RunOnce(); //運(yùn)行進(jìn)程
std::vector<ElemType>::const_iterator NewArrive( int iTime, QCIT it ); //判斷是否有新進(jìn)程入
void ShowList();
bool IsLastOver() const { return bLastOver; }
int GetLastZhouZhuan() const { return nZhouzhuanTime; }
};
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -