OS作業排程中HRN的模擬實現

2021-07-06 10:38:39 字數 918 閱讀 5085

常用的作業排程演算法有先來先服務演算法、短作業優先演算法、響應比高者演算法、優先順序排程演算法和均衡排程演算法等,我們這裡採用高響應比優先排程演算法(hrn)。

c語言**(不完全):

#include #include "string.h"

#define n 10

typedef struct jcb

jcb;

int head; //作業佇列頭指標定義

int tape,printer;

long memory;

jcb jobtable[n]; //作業表

int jobcount=0; //系統內現有作業數量

void schedule() //作業排程函式

//if

}//if

s=p;

p=jobtable[p].next;

}//while

if(q!=-1)

}while(q!=-1);

}//作業排程函式結束

main()

{ char name[4];

int size,tcount,pcount,wtime,rtime;

int p;

memory=65536;

tape=4;

printer=5;

head=-1;

//輸入資料,建立作業佇列

printf("輸入作業名、作業大小、磁帶機數、印表機數、等待時間、估計執行時間\n");

scanf("%s%d%d %d %d %d",name,&size,&tcount,&pcount,&wtime,&rtime);

while(size>=0)

{ if(jobcount

vector的模擬實現

上一節部落格講述了vector常見介面的使用,今天主要是對vector這些介面進行模擬實現,下面是相關 include include includeusing namespace std namespace ty iterator end citerator cbegin const citera...

list的模擬實現

list是stl標準模板庫中的乙個容器,它實質上是乙個帶頭雙向迴圈鍊錶。這樣的好處是 插入 刪除資料時,不用判斷鍊錶是否為空,並且遍歷的時候找尾也很容易,只需要用 head prev就能實現。迭代器的作用就是為了讓容器的訪問像指標一樣可以實現 解引用,以及過載 的比較符。迭代器有兩種實現方式 1.原...

bind的模擬實現

var context context window var result 判斷是否有第二個引數 if arguments 1 else delete context.fn return result var foo function bar name,age bind 方法會建立乙個新的函式。當這...