資源簡介
操作系統實驗
1、先來先服務
2、時間片輪轉
3、最短作業優先
4、最短剩余時間優先
5、非搶占的優先級調度
6、可搶占的優先級調度
7、高響應比調度

代碼片段和文件信息
//?Process?Scheduling.cpp?:?Defines?the?entry?point?for?the?console?application.
//
/*----------------------進程調度模擬程序--------------------*/
/*??????????????????????????????????????????????????????????*/
/*?????????????姓名:萬妮娜????學號:09301049???????????????*/
/*??????????????????????2011.6.12???????????????????????????*/
/*??????????????????????????????????????????????????????????*/
/*----------------------------------------------------------*/
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
#define?inFileName?“Input.txt“
#define?outFileName?“Output.txt“
//隊列結點的定義
typedef?struct?PCBNode{
???int?proID;//進程序號
???int?arriveTime;//進程到達時間
???int?burstTime;//進程請求時間
???int?prior;//進程優先級
???int?finishTime;
???float?rate;//記錄響應比
???bool?first;
???bool?tag;//標記是否已出等待隊列
???PCBNode*?next;
}?PCB;
PCB*?frontw?=?NULL;
PCB*?rearw?=?NULL;
PCB*?frontr?=?NULL;
PCB*?rearr?=?NULL;
int?totalTime?=?0;//已經過去的總時間
int?totalWaitTime?=?0;//總的等待時間
int?totalTurnAroundTime?=?0;?//總的周轉時間
int?totalFinishTime?=?0;
int?proNum?=?0;//進程總數
int?wayNum?=?0;//算法序號
bool?rfirst?=?true;
/*----------------進入等待隊列函數-----------------*/
void?EnWaitQueue(PCB*?p){
rearw->next?=?p;
rearw?=?p;
}
/*----------------進入就緒隊列函數-----------------*/
void?EnReadyQueue(PCB*?p){
rearr->next?=?p;
rearr?=?p;
}
/*----------------出等待序列函數-----------------*/
bool?DeWaitQueue(PCB?&p){
if(frontw?!=?rearw){
p?=?*(frontw->next);
frontw?=?frontw->next;
return?true;
}else{
????return?false;
}
}
/*----------------出就緒序列函數-----------------*/
bool?DeReadyQueue(PCB?&p){
if(frontr?!=?rearr){
p?=?*(frontr->next);
frontr?=?frontr->next;
return?true;
}else{
????return?false;
}
}
/*----------------判斷就緒隊列是否為空-------------------*/
bool?isReadyQueueEmpty(){
if(frontr?==?rearr){
??return?true;
}
return?false;
}
/*---------判斷等待隊列中的進程是否全部進入就緒隊列--------*/
bool?AllWaitOut(){
PCB*?p?=?(PCB*)malloc(sizeof(PCB));
p?=?frontw;
for(int?i=0;i p=p->next;
if(!(p->tag)){//如果P沒有移出了等待隊列
return?false;
}
}
????return?true;
}
/*----------------取等待隊列隊頭元素-------------*/
bool?GetWaitHead(PCB?&p){
if(frontw?!=?rearw){
p?=?*(frontw->next);
return?true;
}else{
????return?false;
}
}
/*----------------取就緒隊列隊頭元素-------------*/
bool?GetReadyHead(PCB?&p){
if(frontr?!=?rearr){
p?=?*(frontr->next);
return?true;
}else{
????return?false;
}
}
/*----------------讀取進程數-----------------*/
void?countProNum(){
std::ifstream??inc;
std::string?temp;
inc.open(inFileName);
while(getline(inctemp)){
???proNum++;
}
inc.close();
}
/*------------讀取進程信息構建等待序列----------*/
void?readFile(){
std::ifstream??inr;
inr.open(inFileName);
frontw?=?rearw?=?(PCB*)malloc(sizeof(PCB));
for(int?i?=?0;i ????????PCB*?temp?=?(PCB*)malloc(sizeof(PCB));
inr>>temp->proID;
inr>>temp->arriv
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????93184??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Debug\Process?Scheduling.exe
?????文件?????451480??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Debug\Process?Scheduling.ilk
?????文件?????732160??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Debug\Process?Scheduling.pdb
?????文件??????14024??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\BuildLog.htm
?????文件?????????67??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\mt.dep
?????文件????????663??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\Process?Scheduling.exe.em
?????文件????????728??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\Process?Scheduling.exe.em
?????文件????????621??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\Process?Scheduling.exe.intermediate.manifest
?????文件?????204602??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\Process?Scheduling.obj
?????文件????3211264??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\Process?Scheduling.pch
?????文件??????12657??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\stdafx.obj
?????文件?????191488??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\vc90.idb
?????文件?????299008??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug\vc90.pdb
?????文件?????????41??2011-05-04?20:20??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Input.txt
?????文件????????934??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Output.txt
?????文件??????31319??2011-06-12?09:45??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Process?Scheduling.cpp
?????文件???????4548??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Process?Scheduling.vcproj
?????文件???????1415??2011-06-12?09:54??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Process?Scheduling.vcproj.2010-VAIO.Administrator.user
?????文件???????1368??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\ReadMe.txt
?????文件????????305??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\stdafx.cpp
?????文件????????320??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\stdafx.h
?????文件????????765??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\targetver.h
?????文件????1313792??2011-06-12?09:54??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling.ncb
?????文件????????920??2011-05-04?19:34??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling.sln
????..A..H.?????12288??2011-06-12?09:54??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling.suo
?????目錄??????????0??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling\Debug
?????目錄??????????0??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Debug
?????目錄??????????0??2011-06-12?09:52??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling\Process?Scheduling
?????目錄??????????0??2011-06-12?09:53??OS_選做實驗一8種進程調度算法模擬實現_09301049\Process?Scheduling
?????目錄??????????0??2011-07-02?15:25??OS_選做實驗一8種進程調度算法模擬實現_09301049
............此處省略3個文件信息
- 上一篇:InnovaDSXP.OCX
- 下一篇:JPEG標準文檔itu-t81
評論
共有 條評論