先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法試驗(yàn)報(bào)告材料_第1頁(yè)
先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法試驗(yàn)報(bào)告材料_第2頁(yè)
先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法試驗(yàn)報(bào)告材料_第3頁(yè)
先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法試驗(yàn)報(bào)告材料_第4頁(yè)
先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法試驗(yàn)報(bào)告材料_第5頁(yè)
已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)用文檔實(shí)驗(yàn)概述:【實(shí)驗(yàn)?zāi)康募耙蟆坷斫獠⒄莆仗幚頇C(jī)調(diào)度算法【實(shí)驗(yàn)原理】基于先來先服務(wù)調(diào)度和最短作業(yè)優(yōu)先調(diào)度算法思想用C語言編程實(shí)現(xiàn)【實(shí)驗(yàn)環(huán)境】(使用的軟件)Visual C+6.0實(shí)驗(yàn)內(nèi)容:本實(shí)驗(yàn)?zāi)M在單處理機(jī)情況下處理機(jī)調(diào)度,用C語言編程實(shí)現(xiàn)先來先服務(wù)和最短作業(yè)優(yōu)先調(diào)度算法。【實(shí)驗(yàn)方案設(shè)計(jì)】FCFS流程圖:向驅(qū)堤LLrs實(shí)用文檔技至U法IM F nJ從刁 的J大X4 UtfTilt辛 了14=&迄出羽 亍*d !EUVjiaWFTd-r JW 各纓*iA 些堆 坦歧整行ITJ I 1MI E遂彼問腴:;:;2L 甲 2 并如時(shí)尋功地面HIxa 理巧若敏并訐*乎坷同酣咐沖試驗(yàn)總設(shè)計(jì)流

2、程圖:實(shí)用文檔進(jìn)程等待時(shí)間=進(jìn)程開始運(yùn)行時(shí)間一進(jìn)程提交時(shí)間(即進(jìn)程處于就緒態(tài)時(shí)間)進(jìn)程周轉(zhuǎn)時(shí)間=進(jìn)程結(jié)束時(shí)間一進(jìn)程提交時(shí)間【實(shí)驗(yàn)過程】(實(shí)驗(yàn)步驟、記錄、數(shù)據(jù)、分析)測(cè)試用例1:屏幕顯示:Please input the total number of jobs輸入:4 屏幕顯示:Please input job number, submit time and run time輸入:19.00.228.50.538.01.049.10.1屏幕顯示:What kind of algorithm do you want? Please input 1 to select FCFS, or 2 to

3、select SJF.輸入:3 屏幕顯示:You have input a wrong number, please input again.輸入:1屏幕輸出結(jié)果:submit run starting final wait turnaround38.01.08.09.00.01.028.50.59.09.50.51.0計(jì)成派計(jì)成派開始時(shí)間,結(jié)束時(shí)間等待時(shí)間,周轉(zhuǎn)時(shí)間按照IO田排序_1FW報(bào)錯(cuò)繼續(xù)輸數(shù)計(jì)算各作業(yè)參數(shù):弗雄蟀廊h據(jù)策憎間等待時(shí)間,周轉(zhuǎn)時(shí)間并輸出實(shí)用文檔19.00.29.59.70.50.749.10.19.79.80.60.7屏幕顯示:The average turnaround

4、 time is 0.85What kind of algorithm do you want? Please input 1 to select FCFS, or 2 to select SJF, or 0 to ex測(cè)試數(shù)據(jù)二:submitrun1 60.52 50.93 6.30.1FCFS和SJF算法結(jié)果一樣:submitrun startingfinalwaitturnaround2 50.9 55.900.91 60.5 66.500.53 6.30.1 6.56.60.20.3The average turnaround time is 0.567測(cè)試數(shù)據(jù)三:submit run

5、150.224.20.335.10.345.20.1FCFS:submit runstartingfinalwait turnaround24.20.3 4.24.500.3150.2 55.200.235.10.3 5.25.50.10.445.20.1 5.55.60.30.4The average turnaround time is 0.325SJF:submit run starting final wait turnaround24.20.34.24.500.3150.255.200.245.20.15.25.300.135.10.35.35.60.20.5The average

6、turnaround time is 0.275源程序:#include stdio.h#include stdlib.h#include string.h#define M 50 struct sjf int jobnumber;實(shí)用文檔float submittime;float runtime;float starttime;float finishtime;float waittime;float turnaroundtime;temp;static struct sjf stM;void input( struct sjf *p, int N)int i;printf( Please

7、 input the job number,submit time and run time:nFor exmple:1 8.5 2for (i =0;i N;i +)scanf( %d%f%f &pi . jobnumber, &pi . submittime, &pi . runtime);void print( struct sjf *p, int N)int k;float h,g;printf( run order: );printf( %d”,p0 . jobnumber);for (k =1;k %d ,pk . jobnumber);printf( nT

8、he processs information:n );printf(njobnumtsubmittruntstarttfinaltwaittturnaroundn);for (k =0;k N;k+)h+=pk . turnaroundtime;printf( %dt%-.1ft%-.1ft%-.1ft%-.1ft%-.1ft%-.1ftn,pk . jobnumber,pk . submittk . waittime,pk . turnaroundtime);g =h/ N;printf( nThe average turnaround time is %-.2fn,g);/*按提交時(shí)間從

9、小到大排序*/void sort1( struct sjf *p, int N)_int i,j;for (i =0;i N;i +)for (j =0;j =i;j +)if (pi . submittime pj . submittime)(temp =pi;實(shí)用文檔pi =pj;pj =temp;/*運(yùn)行*/void deal( struct sjf *p, int N)(int k;for (k =0;k pk-1 . finishtime)(pk . starttime =pk . submittime;pk . finishtime =pk . submittime +pk . r

10、untime;else(pk . starttime =pk -1. finishtime;pk . finishtime =pk -1. finishtime +pk . runtime;for (k =0;k N;k+)(pk . turnaroundtime =pk . finishtime - pk . submittime;pk . waittime =pk . starttime - pk . submittime;實(shí)用文檔void sort2( struct sjf *p, int N)(int next,m,n,k,i;float min;sort1(p,N);for (m=0

11、;mpm-1 . finishtime)(pm . finishtime =pm. submittime +pm. runtime;elsepm . finishtime =pm-1. finishtime +pm. runtime;for (n =m+1;n N;n+)(if (pn . submittime =pm. finishtime) /*判斷內(nèi)存中每次完成之后乂多少到達(dá)的進(jìn)i +;min =pm+1. runtime;next =m+1;for (k=m+1;k m+i;k +)/*找出到達(dá)后的進(jìn)程中運(yùn)行時(shí)間最小的進(jìn)程*/(if (pk+1 . runtime 2兀一一JThe p

12、iocess,s information:obnurnubnitrunstartfinalwaitturnaround-8,01. 0a,og, o0 0L0Lc.0, 3Q. d9,09. S0.3L019.00. 29-59.70. 50.749.10. 1a. 79. S0.G0. 7The average traround tine s 0. 85ffhat kind of algorithm do you want? PLase input 1 to FCFS. or 2 cc selec t SJF or 0 toMH:2run order:3“142I:je proeesi7s

13、inf ornation:,obnuzsucnitrunstartfinalvaitturnaround-8.01. 0&09.00. 01.019.00 2g.o9.20 Q0.2y. 10. 19.30. 10.2-二8.50. 59,39. S0.81.3Ihe average turnaround time M 0* 67iVhat kind cf algorithm do vou want? PLease input 1 to select FCFS+or 2 to seleo測(cè)試二:Pleasel or exwle 111 9. 02 8 53 8.0the job nji

14、ntier, suLnit lirie and run time: & 5 2,0實(shí)用文檔ncDlMXvYuVanXt inAitemp.ewe ithe total numiber of JDbs;3the job lumber, submit 1 ime and run tinted3. 5 2.03 6. 3 0. 1kind c-f algorithm do you want? Please inpuT 1 ro seLect FCFS. or 2 to selec t SJF or 0 ta ex t: r:in order:17一1-一3The proceus inform

15、ation:jobnumsuni trunstartfinal砒litturnaroundi-二5. 00. 95,05,9Q.O0.916. 00. 06.0&S0. 00.53630 I6.5& 60.20.3The aveiage t-irEarcund tine is 0. 57iV-iat kind al ori thm Ho 3PDUwant ? P .ease input 1 to select FCFSar 2 to select SJF or 0 to exit:2run order:2一1一3Izje pioces- - inf uznat ion;.obn

16、wnJUGElltrunstar!finalvaitturnaroundL5.00. 9.05. 90. 00. 91600 56.06.50 J0.536.30. L6.56.60.20.3The averturnaround t iw i 0. 57iVnat kind of algorithm do you wgi? FLcasc inpux 1 to scLcct FCFS* or 2 to sclec t SJF or 0 to exit;半:測(cè)試三:PledgeLlease inrut ForejiizpLe: 11 6 0.52 5 0. 9實(shí)用文檔2 4, 2 0. 33 5.

17、 1 0. 34 5. 2 0- 1ffhot kind of nlsorihm do you wont? P ense input I toSFLCTFCFS, or 2 to selct SJF or 0 to exit:1run or der: 2一1 3一1I he prcfces i m infoymat ion :jobnun:Knitrunstartfinalvaitturnaround.A4.20 34.2150 00.315.00, 2o.Oo.20.00.235. 10. 35.25. 50. 10.1二二5.20 1三,a5, 60 sfl.4The average tu

18、rnaround time is 0.33Kiiit kind of al sat L t hm du you wantJ P lease input 1 to st Lee t FCS, ur 2 to selec t SJF ar 0 to exit:2 run order:2*1一一;一一 土The process* inforraaxian;zobnuzruntartfinalwaitturnaround二1. 20 34.250.00.35.00 2a,05,20 00.24o. 20, 10.23.3。00+1w5 10. 3二33.60. 20.5Ihe aveTage turn

19、around tine is 0. 27ri&t k;nd of alecrilrwi do you vajjt? Please input 1 to select FCF$. or 2 to selec t SJF nr ft to ?x:t:半,【小結(jié)】實(shí)驗(yàn)中產(chǎn)生的錯(cuò)誤及原因分析:測(cè)試用例1的結(jié)果:錯(cuò)誤1:實(shí)用文檔ij 0;*inc2C 1Q4CYuVonbi nwwtcrnp cxcrm order: 3-21/4- The processs information:jobnun submit runstartfinalT?aitturnaround38. 01, 08. 09,

20、0Q 01.028.50.59. 09.50.51. 019.00.29. d9.70. o0,749一10,19 7璀o, e0.7The averagexurnarouncTime Is0, 8ohat kind of algorithm do you want? Please input 1 to select FCFS, or 2 t t SJF or 0 to exit:2 runorder;340-0The process1s information:j obnuiL sjbiiitrunstartfine!waitturnaround8.01.08. 09.00.01.09, 1

21、0. 19. 09. 1-0. 10.0(0.00,09. 10. 19, 19. 100.00.09. 19. 19. 19. 1The average turnaround time is 1. 80Khat kind of algorithm do you vant? Please input 1 tc select FCFS, or 2 tx SJF or 0 to exit:半:半:錯(cuò)誤解決方式:主要是子函數(shù)sort2()中出的錯(cuò):i的作用域,程序修改:將原來:int next,m,n,k,i=0;float min;sort1(p,N);for (m=0;mN;m+)改為:int

22、next,m,n,k,i;float min;sort1(p,N);for (m=0;mpm-1 . finishtime)(pm . finishtime =pm. submittime +pm. runtime;elsepm . finishtime =pm-1. finishtime +pm. runtime;測(cè)試用例3的結(jié)果:錯(cuò)誤1:Flense頃ILease inrut ForejiEule: 11 6 0, 52 5 0.9iVhat kind oft SJF or 0 torun order:2-M-3T5e procesi,information:jebnuraEubmi tr

23、unstartfinnlwaitturnaround5. 00. 95.05. 90.00.9I6.00. 55.96. 1T. 10.1r6,30 16,46,5在1fl. 2The average ffiiiit kind ofdl11lull t SJF or t) toeKLt:.tineci. . - .:i .Fltase inpui 1 to select FCFS. g 2 toturnaroundQr50實(shí)用文檔elsepm . finishtime =pm-1. finishtime +pm. runtime;修改為:elseif (pm . submittime pm-1

24、 . finishtime)pm . finishtime =pm. submittime +pm. runtime;elsepm . finishtime =pm-1. finishtime +pm. runtime; 實(shí)驗(yàn)的體會(huì)及收獲:通過這次試驗(yàn),我對(duì)處理機(jī)的調(diào)度算法特別是FCFS SJF有了更深的理解,而且鍛煉了我的思維能力,使我能更全面地思考問題,以后還需要多做些這方面的練習(xí)。試驗(yàn)不足之處:未在子函數(shù)sort()中未考慮到提交時(shí)間(submittime)大于上個(gè)進(jìn)程的結(jié)束時(shí)間”的情況:錯(cuò)誤分析:同2一樣,解決方法:將原來的:實(shí)用文檔試驗(yàn)未考慮同一時(shí)間提交多個(gè)進(jìn)程的情況,如:測(cè)試數(shù)據(jù):

25、submitrun170.227.20.5370.1結(jié)果應(yīng)該是:FCFS:submitrunstart finalwait turnaround170.27.07.50.00.5370.17.57.60.50.627.20.57.67.80.40.6The average turnaround time is 0.57.SJF:Jobnumsubmitrunstartingfinalwait turnaround370.17.07.10.00.1170.57.17.60.10.627.20.27.67.80.60.6The average turnaround time is 0.43.而程序

26、運(yùn)行結(jié)果是:實(shí)用文檔Please input the job number, t tine and run time;For exncle: 1&呂2, Q1 7 0. 5run order!1-*3?2The process* 5 information:-ebnumsubmitrunstartfinalwai tturnaround17.0O.o7.07. o0.00. 50. 637. 00. 17. 57. 60.52?, 20.27,67. 80,40 6The average turnaround 1imc is 0. 57kind of algorithm do you訴an匕!rit?i2The process s information;zobnmn submitrunat artfinal粗itt-jmaround17. 00.57.07. 50.005

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論