下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
本文格式為Word版,下載可任意編輯——操作系統(tǒng)試驗報告試驗一>i;while(i){}return0;
if(i==1){}
elseif(i==2){
cout>i;
coutnext;
while(p!=0q->next=item;item->next=0;q->next=item;q=p;p=p->next;
PCB*p,*q;q=queue,p=q->next;while(p!=0)
-7-
}
{}
item->next=q->next;q->next=item;
q=p;p=p->next;
voidsort_queue(PCB*temp->next=0;while(queue->next){}
queue->next=temp->next;deletetemp;
PCB*p;p=queue->next;queue->next=p->next;insert_queue(temp,p);
PCB*newp=0;staticlongid=0;newp=newPCB;id++;newp->ID=id;newp->State=0;newp->CPUtime=0;
-8-
}
newp->priority=rand()%3+1;newp->ALLtime=rand()%3+1;newp->next=NULL;
pushback_queue(ready_queue,newp);//print(newp);
//coutnext=0;ready_queue=newPCB;ready_queue->next=0;
inti=0,pcb_number=-1;/*閑逛進程放入就緒隊列*/idleprocess=NULL;
idleprocess=(PCB*)malloc(sizeof(PCB));idleprocess->ID=0;idleprocess->State=0;idleprocess->CPUtime=0;idleprocess->priority=0;idleprocess->ALLtime=0;idleprocess->next=NULL;
idleprocess->next=ready_queue->next;/*閑逛進程放入就緒隊列*/
-9-
ready_queue->next=idleprocess;
//也可以假定初始時系統(tǒng)中只有一個idle進程//輸入初始進程的個數
while(pcb_number>pcb_number;
coutState=2;pcb->CPUtime-=2;if(pcb->CPUtimeblocked\\n\pcb->next=block_queue->next;block_queue->next=pcb;
pcb->CPUtime+=2;
ID==0){}else{
pcb->State=1;pcb->CPUtime+=4;
pcb->priority=pcb->priority-3;/*每運行一個時間片,其優(yōu)先數減3*/if(pcb->priorityrunning\\n\
print(pcb);
printf(\變遷1:ready->running\\n\
if(rand()%3==1)/*PCB不是閑逛進程,滿足條件側阻塞此進程*/{
if(pcb->CPUtime-2ALLtime)
block(pcb);
else/*已執(zhí)行完畢,應當銷毀進程*/{}
-12-
coutrunning\\n\
else{}
if(rand()%5==1){}
if(rand()%7==1)
wakeup();insert(3);pcb->State=1;
pcb->CPUtime=pcb->ALLtime;print(pcb);
printf(\變遷1:ready->running\\n\
if(rand()%3==1)/*PCB不是閑逛進程,滿足條件側阻塞此進程*/{}else{}
coutDestrory\deletepcb;
_state=1;block(pcb);
voidproc_priority()//優(yōu)先權調度算法模擬{
sort_queue(ready_queue);PCB*temp=0,*running=0;
-14-
}
inttimes=0;coutnext;ready_queue->next=running->next;coutnext;ready_queue->next=running->next;cout0){
times=times-running->ALLtime;/*每次運行一個進程減去ALLtime;*/if(times>=0){
Run_loop(running);
-15-
}}
}
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- CUSTOM YACHT BUILDING CONTRACT(定制游艇建造合同)
- 二級建造師服務合同樣本
- 養(yǎng)殖基地轉讓合同范本年
- 機床設備采購的合同范本
- 簡單快遞服務合同
- 園林綠化建設工程施工合同
- 毛石采購合同
- 勞動合同河南省勞動合同
- 居間合同土地出讓
- 實現智慧城市建設項目合同
- 2024年聯(lián)勤保障部隊第九四〇醫(yī)院社會招聘考試真題
- 第二章《有理數的運算》單元備課教學實錄2024-2025學年人教版數學七年級上冊
- DB31-T 596-2021 城市軌道交通合理通風技術管理要求
- 華為智慧園區(qū)解決方案介紹
- 2022年江西省公務員錄用考試《申論》真題(縣鄉(xiāng)卷)及答案解析
- 人教版八年級英語上冊期末專項復習-完形填空和閱讀理解(含答案)
- 一例蛇串瘡患者個案護理課件
- 低壓電工理論考試題庫低壓電工考試題
- 國家電網培訓課件
- 五年級上冊口算練習400題及答案
- 駱駝祥子選擇題100道及答案
評論
0/150
提交評論