freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

優(yōu)先級法、多級反饋輪轉(zhuǎn)法_進程調(diào)度模擬設(shè)計(編輯修改稿)

2024-08-23 09:42 本頁面
 

【文章內(nèi)容簡介】 H__ include include include include include include int main(int argc, char *argv[]) { char mand。 srand( (unsigned)time(NULL) )。 restart()。 while((mand = get_mand()) != 39。039。)。 } //接收用戶選擇并轉(zhuǎn)入相應(yīng)的操作 char get_mand() { char c。 printf(\n[%d 個進程正在進行中 , %s, %s,如果遇到問題,請按 39。639。查詢 ]\n 請選擇將要進行的操作 :\n,pre_list_size,algo_name,oper_name)。 c = _getch()。 switch(c) { case 39。139。:add_process()。break。 case 39。239。:switch_algorithm()。break。 case 39。339。: if(algorithm == 0) start_scheduling()。 else start_scheduling_rrmf()。 break。 case 39。439。:calculate_time_costs()。break。 case 39。539。:view_list(pre_list)。break。 case 39。639。:help_menu()。break。 case 39。739。:restart()。break。 case 39。839。:man_auto()。break。 } return c。 } // 手動 /自動 切換 void man_auto() { if(manual == 0) { printf(切換為 39。自動模式 39。\n)。 strcpy(oper_name, Automatic)。 manual = 1。 } else { printf(切換為 39。手動模式 39。\n)。 strcpy(oper_name, Manual)。 manual = 0。 } } //顯示幫助菜單 void help_menu() { printf( === Process Scheduler Simulator ===\n \n (目前算法為 : %s)\n \n 、平均帶權(quán)周轉(zhuǎn)時間 \n \n \n \n 、自動切換 (目前模式為 : %s)\n \n,algo_name,oper_name )。 } // 添加 node 于 head 所指隊列的隊尾 void append(struct PCB **head, struct PCB **node) { struct PCB *p。 //(*node)next=NULL。 if(*head==NULL){ *head=*node。 return。 } else{ p=*head。 while(pnext!=NULL) p=pnext。 pnext=*node。 } } //添加進程 void add_process() { int counterpart, i。 struct PCB *tmp。 struct PCB *p = malloc( sizeof(struct PCB) )。 printf(請輸入進程名稱 :)。 scanf(%s, pname)。 if(algorithm == 0) // SRR 線性優(yōu)先級調(diào)度 ppriority = 0。 //優(yōu)先級為 0,表明使用 SRR else // RRMF 多級反饋輪轉(zhuǎn)法 ppriority = PRIORITY1。 puse_slices = USE_SLICES1。 // RRMF 專用,表示占用的時間片 parrive_time = 2 * add_idx + rand() % 1。 pused_run_time = 0。 psleep_time = 1。 pfinish_time = 1。 pnext = NULL。 printf(請輸入需要的時間片數(shù) :)。 scanf(%d, amp。prun_time)。 // 需要的時間片數(shù) append(amp。pre_list, amp。p)。 add_idx ++。 // 第幾輪添加進程 pre_list_size ++。 // 是否隨機增加幾個同時刻的進程 printf(請輸入同時刻的進程數(shù) :)。 scanf(%d,amp。counterpart)。 if(counterpart0) { for(i = 0。 icounterpart。 i++) { tmp = malloc( sizeof(struct PCB) )。 sprintf(tmpname, %s_%d, pname, i)。 tmppriority = ppriority。 tmparrive_time = parrive_time。 tmprun_time = prun_time。 tmpused_run_time = 0。 tmpuse_slices = puse_slices。 // RRMF 專用 tmpsleep_time = 1。 tmpfinish_time = 1。 tmpnext = NULL。 append(amp。pre_list, amp。tmp)。 } pre_list_size += counterpart。 } else counterpart = 0。 printf(成功增加 %d 個進程! \n, 1+counterpart)。 } // 查看隊列中內(nèi)容 void view_list(struct PCB *list) { struct PCB *p。 if(list == NULL) printf( Empty \n)。 else { printf(\n)。 p = list。 while(p != NULL) { printf( )。 show_process(p)。 //顯示進程內(nèi)容 printf(\n)。 p = pnext。 } } } //顯示進程內(nèi)容 void show_process(struct PCB *node) { printf([%6s 優(yōu)先級 :%3d 到達時間 :%3d 需要的時間片數(shù) :%3d 已經(jīng)用過的時間片數(shù) :%3d 進程阻塞耗時 :%3d 完成時間 :%3d 每次占用 CPU 消耗的時間片數(shù) :%3d 下一個 :%5s] , nodename, nodepriority, nodearrive_time, noderun_time, nodeused_run_time, nodesleep_time, nodefinish_time,nodeuse_slices, nodenext==NULL?NULL:nodenextname)。 } // 切換調(diào)度算法(線性優(yōu)先級法,多級反饋輪轉(zhuǎn)法) void switch_algorithm() { struct PCB *tmp。 if(algorithm == 0) { // 調(diào)度算法標記 , 0SRR 1RRMF 默認為 0 printf(切換至 39。多級反饋輪轉(zhuǎn)算法 39。\n)。 strcpy(algo_name, RRMF)。 algorithm = 1。 // SSR 狀態(tài)下添加的進程的 Priority 默認為 0,改為 PRIORITY1 tmp = pre_list。 while(tmp != NULL) { tmppriority = PRIORITY1。 tmp = tmpnext。 } } else { printf(切換至 39。線性優(yōu)先級算法 39。\n)。 strcpy(algo_name, SSR)。 algorithm = 0。 } } // 計算并顯示平均周轉(zhuǎn)時間,平均帶權(quán)周轉(zhuǎn)時間 void calculate_time_costs() { struct PCB *p。 float sum = , weighted_sum=。 int num = 0。 // 統(tǒng)計 PCB 個數(shù) if(finished_list == NULL) printf(完成隊列為空 !\n)。 else { p = finished_list。 // 完成隊列 while(p != NULL) { sum += (pfinish_time parrive_time) * 。 weighted_sum += (pfinish_time parrive_time) * / prun_time。 num ++
點擊復(fù)制文檔內(nèi)容
研究報告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1