程序排程實現 C語言

2021-10-01 18:54:23 字數 1570 閱讀 6697

程序排程實現–c語言

本程式主要來自但是鏈結裡的短程序優先排程演算法有些錯誤實現不了,這是我修改後的程式,裡面也有c++語言。

去部落格設定頁面,選擇一款你喜歡的**片高亮樣式,下面展示同樣高亮的**片.

#include

#include

#include

using namespace std;

struct node job[10]

;//按到達時間排序

void

arrive_sort

(int num)}}

}void

service_sort

(int num)}}

}}//如果到達時間相等,服務時間按從小到大排序

void

arrive_short_sort

(int num)

else}}

}}}void

fcfs

(int num)

//先來先服務

else

job[i]

.taccomplish = job[i]

.tstart + job[i]

.tservice;}}

void

sjf(int num)

//短作業優先

else

job[i]

.taccomplish = job[i]

.tstart + job[i]

.tservice;};

service_sort

(num)

;for

(int i =

0; i < num; i++

)else

job[i]

.taccomplish = job[i]

.tstart + job[i]

.tservice;}}

void

rr(int num)

//rr演算法

else

time = job[i]

.tstart;

if(job[i]

.if_finish ==1)

continue

;//該程序已完成

else

else

if(job[i]

.tsurplus > q && time >= job[i]

.tarrive)

//未完成且大於乙個時間片

if(job[i]

.if_finish ==

1) finish_pro++

;//乙個程序完成加一

} c++;}

break;}

}//輸出

void

print

(int num)

}void

display

(int num)

}while

(ch !=4)

;}int main()

display

(num)

;return0;

}

程序排程演算法(c語言)

對乙個非搶占式多道批處理系統採用以下演算法的任意兩種,實現程序排程,並計算程序的開始執行時間,周轉時間,帶權周轉時間,平均周轉時間,平均帶權周轉時間 1.先來先服務演算法 2.短程序優先演算法 3.高響應比優先演算法 一 設計思想 每個程序有乙個程序控制塊 pcb 表示。程序控制塊可以包含如下資訊 ...

短程序優先 SPF 排程演算法 C語言實現

include include define num 20 0 2 3 54 4 6 58 2 1 1 不包含同時到達情況 必須排除位置資訊!void print int a,int j int arr fin,arr turn,min w,min m 0,print f double arr ri...

作業系統 程序排程(C語言)

include include include include using namespace std struct pcb type typedef struct queuenode 佇列鍊錶 queuelink 設定全程變數 struct queuenode ready head null,re...