![PV原語的模擬實(shí)現(xiàn)_第1頁](http://file4.renrendoc.com/view/0ddba3694f62c7d81c66471bfe6b94c5/0ddba3694f62c7d81c66471bfe6b94c51.gif)
![PV原語的模擬實(shí)現(xiàn)_第2頁](http://file4.renrendoc.com/view/0ddba3694f62c7d81c66471bfe6b94c5/0ddba3694f62c7d81c66471bfe6b94c52.gif)
![PV原語的模擬實(shí)現(xiàn)_第3頁](http://file4.renrendoc.com/view/0ddba3694f62c7d81c66471bfe6b94c5/0ddba3694f62c7d81c66471bfe6b94c53.gif)
![PV原語的模擬實(shí)現(xiàn)_第4頁](http://file4.renrendoc.com/view/0ddba3694f62c7d81c66471bfe6b94c5/0ddba3694f62c7d81c66471bfe6b94c54.gif)
![PV原語的模擬實(shí)現(xiàn)_第5頁](http://file4.renrendoc.com/view/0ddba3694f62c7d81c66471bfe6b94c5/0ddba3694f62c7d81c66471bfe6b94c55.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
PV原語的模擬實(shí)現(xiàn)P、V原語的模擬實(shí)現(xiàn)本課題實(shí)習(xí)的目的是,加深對進(jìn)程概念及進(jìn)程管理各部分內(nèi)容的理解;熟悉進(jìn)程管理中主要數(shù)據(jù)結(jié)構(gòu)的設(shè)計(jì)及進(jìn)程調(diào)度算法,進(jìn)程控制機(jī)構(gòu)、同步結(jié)簡單的進(jìn)程控制、同步及通迅機(jī)構(gòu),其進(jìn)程調(diào)度算法可任意選擇。每個(gè)進(jìn)程用功能測試并得出正確結(jié)果。中畫出P和V函數(shù)流程圖;本實(shí)驗(yàn)針對操作系統(tǒng)中信號量相關(guān)理論進(jìn)行實(shí)驗(yàn),要求實(shí)驗(yàn)者輸入實(shí)驗(yàn)指記錄型信號量采用了“讓權(quán)等待”的策略,存在多個(gè)進(jìn)程等待訪問同一臨#include<stdio.h>#defineTRUE1#defineFALSE0#defineMAXPRI100#defineNIL-1rsaveareaaddrLrjjj{pcb[j].id=j;pcbjstatus='r';pcbjnextwrNIL;printf"\nprocess%dpriority",j+1);pcbjpriorityi;}mvaluesemfirstwrNILmvaluesemfirstwrNILriiirjjjj}mm=-seed;seedseed64416;returnm/12565.0);}addr{ndomxexereturnFALSEexereturnFALSExereturnFALSEiaddrpcbexe.status='t';printfTimessilceinterruptnprocessdenterintoready\n",exe+1);nTRUE}{rjjjw=pcb[j].priority;pd=j;}rjjj{w=pcb[j].priority;pd=j;}urnpd}{ILexeNILurnNIL{pcbpd.status='e';printf("process%disexecuting.\n",exe+1);}elseif(pcb[pd].priority<pcb[exe].priority){pcb[exe].status='r';printf("process%denterintoready\n",exe+1);pcb[pd].status='e';printf("process%denterintoready\n",exe+1);}}addrsaveareaexe[1];eturnexe}kintse{printf("process%disblocked\n",exe+1);pcb[exe].status='w';pcb[exe].nextwr=NIL;ifwsemsefirstwr=NIL)sefirstwrexewhile(pcb[w].nextwr!=NIL)w=pcb[w].nextwr;pcb[w].nextwr=exe;}}p(intse,charad){ifsem[se].value>=0)return(FALSE);block(se);veareaexeiaveareaexeadreturn(TRUE);}wakeup(intse){w=sem[se].firstwr;twrpcbwnextwrpcbwstatus='r';printf"process%diswakenup\n",w+1);}}secharad{uereturnFALSEwakeup(se);adiurnTRUE}{pcbnstatusc;printfprocessdiscompletednn1);}ssl{ii{printfprocesscallsPonthesemaphorenrintfprocessisexecutinginthecreticalsectionnbprintfs%d\n",++s1);printfprocesscallsVonsemaphorelandquitcreticalsectionnfprocesscallsPonesemaphorelnfprocessisexectingcreticalsectionnrintfsdnsprintfprocesscallsVonsemaphoreandquitcreticalsectionn;intfprocesscyclecountdni}}ocess{foriii{printf("process2callsPonthesemaphore2\n");rintfprocessisexecutinginthecreticalsectionnbprintfs%d\n",++s2);printfprocesscallsVonsemaphoreandquitcreticalsection2.\n");printfprocesscallsPonesemaphorenprintfprocessisexectingcreticalsectionnrintfsdnsprintfprocesscallsVonsemaphoreandquitcreticalsection1.\n");intfprocesscyclecountdni}}ocess{foriii{printf("process1,callsPonsemaphore2\n");ifpabreakprocessisbiockeda1:printf("process1isexeccutingonitscreticalsection\n");b1:printf("s2=%d\n",++s2);printf("process1callsVonsemapore2andquitcreticalsection\n");vcbreakwakeupabiockedprocesscprintfprocesscyciencount=%d\n",i);}}main{printf("****processmanagement****\n\n");printf("s1=%d,s2=%d\n",s1,s2);printf("process1,process2,process1areallin
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年七年級歷史下冊 第16課 明朝的科技、建筑與文學(xué)說課稿 新人教版
- 2025瓷磚買賣合同
- Unit 3 Family Matters Understanding ideas Like Father,Like Son 說課稿 -2024-2025學(xué)年高中英語外研版(2019)必修第一冊
- 2024-2025學(xué)年高中語文 第三課 第4節(jié) 咬文嚼字-消滅錯(cuò)別字說課稿2 新人教版選修《語言文字應(yīng)用》
- 21 古詩三首 第一課時(shí) 說課稿-2024-2025學(xué)年統(tǒng)編版語文四年級上冊
- 2025購銷合同范本
- 森林安全監(jiān)管方案
- 企業(yè)派駐合同范例
- 網(wǎng)狀吊索拱橋施工方案
- 黔東南綠化草坪施工方案
- 新生兒黃疸早期識別課件
- 醫(yī)藥營銷團(tuán)隊(duì)建設(shè)與管理
- 新生兒氣管插管操作評分標(biāo)準(zhǔn)
- 二年級數(shù)學(xué)上冊口算題100道(全冊完整)
- 冷軋工程專業(yè)詞匯匯編注音版
- 小升初幼升小擇校畢業(yè)升學(xué)兒童簡歷
- 第一單元(金融知識進(jìn)課堂)課件
- 五年級語文閱讀訓(xùn)練20篇專項(xiàng)訓(xùn)練帶答案解析
- 介入導(dǎo)管室護(hù)士述職報(bào)告(5篇)
- GB/T 37062-2018水產(chǎn)品感官評價(jià)指南
- 零件的工藝分析及毛坯選擇
評論
0/150
提交評論