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

📄 cpcb.h

📁 操作系统课程设计~处理机调度 模拟一种多任务(或多用户)(多道)批处理操作系统(包含处理器管理、存储管理、进程管理。
💻 H
字号:
#ifndef CPCB_H
#define CPCB_H

#define TASK_RESERVE  0
#define TASK_READY	  1
#define TASK_RUNNING  2
#define TASK_WAITE	  3
#define TASK_HANG	  4
#define TASK_OVER	  5
#define MAX_PID		  100
#define MAX_PRIO	  20
#define DEFAULT_TIME_SLICE 10
#define DEFAULT_MEMORY_SIZE 10
typedef unsigned int uint;
/*要使用Clist,需提供prep,nextp,和<(),>()*/
class Cpcb
{
public:
	int pid;
	int state;
	int priority;	
	int time_slice;	//要求运行时间
	int time_ran;	//已运行时间
	uint memory;
	uint mm_begin;
	Cpcb* prep;
	Cpcb* nextp;
	Cpcb():pid(0),state(0),priority(0),time_slice(0),time_ran(0),prep(NULL),nextp(NULL),memory(DEFAULT_MEMORY_SIZE),mm_begin(0){}
	bool run()
	{		
		if( time_ran<time_slice )
		{
 			if( priority>0 ) --priority;
 			++time_ran;
			state=TASK_RUNNING;
			return true;
		}
		else
		{
			state=TASK_OVER;
			return false;
		}
	}
	bool operator <(Cpcb& p) const
	{
		return this->priority<p.priority;
	}
	bool operator >(Cpcb& p) const
	{
		return this->priority>p.priority;
	}
};
#endif

⌨️ 快捷键说明

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