xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 431KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-16
  • 語言: 其他
  • 標簽: 操作系統??

資源簡介

操作系統實驗二 時間片輪轉RR進程調度算法(內含源代碼和詳細實驗報告),詳細介紹:http://blog.csdn.net/xunciy/article/details/79239096

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
using?namespace?std;

//存放每個進程信息的結構體
typedef?struct{
????char?name;//進程名字
????int?ArrivalTime;//到達時間
????int?ServiceTime;//服務時間
????int?FinishedTime;//完成時間
????int?WholeTime;//周轉時間
????double?WeightWholeTime;//帶權周轉時間
}RR;

static?queueRRqueue;??//用來模擬進程執行RR調度算法的隊列
static?double?SumWT=0SumWWT=0AverageWT?=0AverageWWT=0;//平均周轉時間、平均帶權周轉時間
static?int?q;??//時間片數
static?int?n;??//進程個數
static?RR?RRarray[100];??//進程結構體
static?RR?temp;??//進程結構

void?Enter();//輸入時間片、到達時間、服務時間等
void?RRfunction();//執行RR調度算法
void?display();//顯示各時間執行情況,以及各個時間值

int?main(){
????Enter();
????RRfunction();
????display();
????return?0;
}

//輸入時間片、到達時間、服務時間等
void?Enter(){
????int?ij;
????cout<<“Enter?n:?“;
????cin>>n;
????cout<<“Enter?TimeSlice?q:?“;
????cin>>q;

????for?(i=0;i??????RRarray[i].name=i+65;//自動將進程名字順序編號為A、B、C、D、E等
????}

????cout<<“Enter?ArrivalTime:?“;
????for?(i=0;i??????cin>>RRarray[i].ArrivalTime;
????}

????cout<<“Enter?ServiceTime:?“;
????for?(i=0;i??????cin>>RRarray[i].ServiceTime;
????}

????//根據達時間排序
????for(i=0;i????????for(j=i+1;j????????????if(RRarray[i].ArrivalTime?>?RRarray[j].ArrivalTime)?{
????????????????temp?=?RRarray[i];
????????????????RRarray[i]?=?RRarray[j];
????????????????RRarray[j]?=?temp;
????????????}
????????}
????}
}

//執行RR調度算法
void?RRfunction(){
????char?Moment[100];???//存儲每個時間片p對應的進程名稱
????RRqueue.push(RRarray[0]);???//第一個進程進隊列

????int?MomentPoint?=?0;
????int?CurrentTime=0;
????int?tempTime;???//控制CurrentTime的累加時間,當前進程的服務時間小于時間片q的時候,起到重要作用
????int?i=1jkp;??//指向還未處理的進程的下標
????int?finalNumber?=?0;???//執行RR算法后,進程的個數
????int?Time[50];

????//判斷第一個進程的服務時間是否大于時間片,如果大于CurrentTime=q,如果小于CurrentTime=服務時間
????if?(RRarray[0].ServiceTime>=q)
????????CurrentTime?=?q;
????else
????????CurrentTime?=?RRarray[0].ServiceTime;

????while(!RRqueue.empty()){
????????for?(j=i;j????????????if?(RRarray[j].name!=NULL?&&?CurrentTime?>=?RRarray[j].ArrivalTime){
????????????????RRqueue.push(RRarray[j]);
????????????????i++;
????????????}
????????}
????????if?(RRqueue.front().ServiceTime????????????tempTime?=?RRqueue.front().ServiceTime;
????????else
????????????tempTime?=?q;

????????RRqueue.front().ServiceTime?-=?q;???//進程每執行一次,就將其服務時間?-q

????????//將隊首進程的名稱放入數組中
????????Moment[MomentPoint]?=?RRqueue.front().name;
????????MomentPoint++;
????????Time[finalNumber]?=?tempTime;
????????finalNumber++;


????????if?(RRqueue.front().ServiceTime?<=?0)??//把執行完的進程退出隊列
????????????RRqueue.pop();???//如果進程的服務時間小于等于,即該進程已經服務完了,將其退棧
????????else{
????????????//將隊首移到隊尾
????????????RRqueue.push(RRqueue.front());
????????????RRqueue.pop();
????????}
????????CurrentTime?+=?tempTime;

????}

????//進程各時間進程狀態,計算完成時間
????cout<<“Time?0:?“;
????Time[finalNumber]=0;
????int?time?=?Time[0];
????f

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-02-02?14:31??實驗二??時間片輪轉RR進程調度算法\
?????目錄???????????0??2018-02-02?14:27??實驗二??時間片輪轉RR進程調度算法\2.RR\
?????文件????????5556??2017-12-14?11:29??實驗二??時間片輪轉RR進程調度算法\2.RR\RR.cpp
?????文件?????1075201??2017-12-14?11:29??實驗二??時間片輪轉RR進程調度算法\2.RR\RR.exe
?????文件???????43166??2017-12-14?11:29??實驗二??時間片輪轉RR進程調度算法\2.RR\RR.o
?????文件??????141289??2017-12-28?22:10??實驗二??時間片輪轉RR進程調度算法\實驗二??時間片輪轉RR進程調度算法.docx

評論

共有 條評論