schedule.cpp

来自「操作系统的页面调度算法」· C++ 代码 · 共 57 行

CPP
57
字号
// schedule.cpp: implementation of the schedule class.
//
//////////////////////////////////////////////////////////////////////

#include "schedule.h"
#include<fstream.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

schedule::schedule(char *fn)
{
	T=W=0;
	ifstream in("fn");
	int start,cost;
	if(!in){
	  cout<<"Can not open file!\n";	  
	}
	while(!in.fail())	
	{		
		in>>start>>cost;
		process* p=new process(start,cost);
		Quesche.insert(p);	
		Quesche.length++;
	}
}

void schedule::FCFS(void)
{
	process* p=Quesche.head;
	process* q=p->next;
	while(q!=NULL)
	{
		q->begin_executetime=p->finishtime;
		q->finishtime=q->begin_executetime+q->costtime;
		q->finish=true;
		q->perT=q->finishtime-q->arrtime;
		q->perW=q->perT/q->costtime;
		T=T+q->perT;
		W=W+q->perW;
		p=q;
		q=q->next;
	}
	T=T/Quesche.length;
	W=W/Quesche.length;
}


void schedule::SJF(void)
{
	
}
schedule::~schedule()
{

}

⌨️ 快捷键说明

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