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

📄 main.h

📁 一个学习操作系统原理很好的演示程序.演示进程调度与读写者的同步问题
💻 H
字号:
// Main.h: interface for the Main class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAIN_H__EA415623_EB56_4EC4_858F_0150E32A792F__INCLUDED_)
#define AFX_MAIN_H__EA415623_EB56_4EC4_858F_0150E32A792F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "stdafx.h"

#define NEW 1
#define READY 2
#define ENDED 3
#define MAXSIZE 30
#define RUNNING 4

typedef struct pcb
{
	char name[10];
	int ID;
	int timeStart;
	int timeLeft;
	int timeUsed;
	int priority;
	int round;
	int state;
	int timeEnded;
	pcb * next;
}PCB,*PPCB;

class Engine
{
protected:
	PCB a[MAXSIZE];
	PCB b[MAXSIZE];
	int numOfProcess;
	PPCB newHead,readyHead,running,endedHead;
	int runningCount;
	int timeSlice;
	bool ended;
	CString message[4];
	bool hasMessage;
	int numMessage;
public:
	Engine();
	void CreateProcesses(int num,int maxPriority,int maxStartTime,int maxExeTime);
	void CopyProcesses();
	void InitQueue();
	PPCB getNewHead();
	PPCB getReadyHead();
	PPCB getRunning();
	PPCB getEndedHead();
	bool IsEnded(){return ended;};
	CString * getMessage(int * n){ *n=numMessage;return message;};
	bool HasMessage(){return hasMessage;};
	PPCB getA(){return a;};
	PPCB getB(){return b;};
	int getNum(){return numOfProcess;};
	void copyEngine(Engine* e){ numOfProcess=e->getNum();memcpy(a,e->getA(),numOfProcess*sizeof(PCB));};
	void setTimeSlice(int i);
	virtual void addToReady(PPCB p)=0;
	void MoveNewToReady(int time);
	void MoveRunning(int time);
	void MoveReadyToRunning(int time);
	void StepTo(int time);
};

class PriorityEngine:public Engine
{
public:
	PriorityEngine();
	void addToReady(PPCB p);
};

class RoundEngine:public Engine
{
public:
	void addToReady(PPCB p);
};


#endif // !defined(AFX_MAIN_H__EA415623_EB56_4EC4_858F_0150E32A792F__INCLUDED_)

⌨️ 快捷键说明

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