九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告

上傳人:仙*** 文檔編號(hào):30235322 上傳時(shí)間:2021-10-09 格式:DOC 頁(yè)數(shù):48 大?。?22.50KB
收藏 版權(quán)申訴 舉報(bào) 下載
中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告_第1頁(yè)
第1頁(yè) / 共48頁(yè)
中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告_第2頁(yè)
第2頁(yè) / 共48頁(yè)
中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告_第3頁(yè)
第3頁(yè) / 共48頁(yè)

下載文檔到電腦,查找使用更方便

15 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告》由會(huì)員分享,可在線閱讀,更多相關(guān)《中南大學(xué) 操作系統(tǒng)實(shí)驗(yàn)報(bào)告課程設(shè)計(jì)報(bào)告(48頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、操作系統(tǒng)實(shí)驗(yàn)報(bào)告界面設(shè)計(jì)l 菜單菜單包括菜單欄,菜單,菜單項(xiàng),一個(gè)菜單欄可以包括N個(gè)菜單,一個(gè)菜單可以包括菜單項(xiàng)。C語言設(shè)計(jì)菜單的思想是用雙向鏈表,先保存繪圖區(qū)的內(nèi)容,再在上面畫菜單。l 菜單結(jié)構(gòu)圖菜單欄菜單1菜單2菜單n.尾指針頭指針當(dāng)前指向菜單菜單項(xiàng)1菜單項(xiàng)2。菜單項(xiàng)n頭指針其他菜單項(xiàng)結(jié)構(gòu)類似結(jié)尾指針l 數(shù)據(jù)結(jié)構(gòu)1. 菜單欄:typedef struct menubar_sint number,x,y,barheight,baritemwidth;/*number用來記錄菜單項(xiàng)的數(shù)目,x,y用來記錄菜單欄在屏幕上的位置,barheight用來控制菜單欄的高度,baritemwidth用來控

2、制每項(xiàng)菜單的寬度*/struct menu_s *mhead; /*指向第一個(gè)菜單*/struct menu_s *mtail; /*指向最后一個(gè)菜單*/struct menu_s *mpoint; /*當(dāng)用戶按下左右箭頭時(shí)用來記錄指向那個(gè)菜單,初始指向mhead*/void (* docommand)(); /*菜單時(shí)間的處理函數(shù)*/MenuBar;2. 菜單:typedef struct menu_sint number; /*菜單是菜單欄中的第幾項(xiàng)*/int subwidth; /*菜單項(xiàng)的寬度*/int subcount; /*菜單項(xiàng)的數(shù)目*/char *content; /*菜單顯示

3、的字符串/struct menu_s *next; /*指向下一個(gè)菜單,如果是結(jié)尾菜單,則為NULL*/struct menu_s *before; /*指向前一個(gè)菜單,如果是頭菜單,則為NULL*/struct submenu_s *sub; /*指向當(dāng)前激活的菜單項(xiàng)*/struct submenu_s *head; /*指向第一個(gè)菜單項(xiàng)*/struct submenu_s *tail; /*指向最后一個(gè)菜單項(xiàng)*/Menu;3. 菜單項(xiàng):typedef struct submenu_sint number; /*菜單項(xiàng)是菜單中的第幾項(xiàng)*/int isactive; /*是否激活*/char

4、*content; /*顯示的字符串*/struct submenu_s *next; /*指向下一個(gè)菜單項(xiàng)*/struct submenu_s *before; /*指向前一個(gè)菜單項(xiàng)*/submenu;l 函數(shù)實(shí)現(xiàn)1. 菜單構(gòu)造函數(shù)/*該函數(shù)的功能主要是根據(jù)指定的menutitle字符串,往菜單欄中添加一項(xiàng)菜單*/void addmenu(char *menutitle)if(Mb=NULL)/*如果Mb(全局MenuBar類型的變量)為NULL,說明沒有初始化菜單欄,要初始化*/if(Mb=(MenuBar *)malloc(sizeof(MenuBar)=NULL)doerror(Sys

5、tem error);Mb-number=0; /*菜單欄中菜單數(shù)目為0*/Mb-mpoint=Mb-mhead=Mb-mtail=NULL;Mb-x=0;Mb-y=0; /*位置于屏幕上(0,0)*/Mb-barheight=18; /*菜單欄高度為18*/Mb-baritemwidth=100; /*每項(xiàng)菜單的寬度為100*/Mb-docommand=docommand; /*設(shè)置事件處理函數(shù)為docommand()*/if(Mb-mtail=NULL) /*如果Mb-mtail為NULL,說明要先構(gòu)造Mb-mhead*/if(Mb-mhead=(Menu *)malloc(sizeof(

6、Menu)=NULL)doerror(System error);Mb-mhead-before=NULL;Mb-mtail=Mb-mhead;else if(Mb-mtail-next=(Menu *)malloc(sizeof(Menu)=NULL)doerror(System error);Mb-mtail-next-before=Mb-mtail;Mb-mtail=Mb-mtail-next;Mb-mtail-number=Mb-number; /*當(dāng)前添加進(jìn)去的菜單位置,下面有Mb-number的自加*/Mb-mtail-subwidth=0; /*菜單項(xiàng)的寬度為0*/Mb-mtai

7、l-subcount=0; /*菜單項(xiàng)數(shù)目為0/Mb-mtail-content=menutitle; /*把菜單的字符串指針指向menutitle*/Mb-mtail-next=NULL;Mb-mtail-sub=Mb-mtail-head=Mb-mtail-tail=NULL; /*把菜單項(xiàng)全部置NULL*/Mb-number+;/*菜單欄中number加1,表示加進(jìn)去了一個(gè)菜單*/ 2. 菜單項(xiàng)構(gòu)造函數(shù)/*該函數(shù)的功能是根據(jù)menu指定的字符串,往該菜單中添加以itemtitle為字符串的菜單項(xiàng)比如additem(“File”,”O(jiān)pen”)則執(zhí)行向File菜單中添加一項(xiàng)itemtitl

8、e菜單項(xiàng)*/void additem(char *menu,char *itemtitle) Mb-mpoint=Mb-mhead; /*先把指針指向菜單頭,這里借用Mb中的mpoint為了不用額外的變量*/ while(Mb-mpoint!=NULL) if(stricmp(Mb-mpoint-content,menu)=0) /*遍歷menu鏈表,如果找到一項(xiàng)和menu指定字符串相等的,則記錄下來,跳出,*/ break; Mb-mpoint=Mb-mpoint-next; if(Mb-mpoint-tail=NULL) /*如果tail為空,則說明沒有構(gòu)造頭節(jié)點(diǎn)head*/ if(Mb-

9、mpoint-head=(submenu *)malloc(sizeof(submenu)=NULL) doerror(System error); Mb-mpoint-head-before=NULL; Mb-mpoint-sub=Mb-mpoint-tail=Mb-mpoint-head; else if(Mb-mpoint-tail-next=(submenu *)malloc(sizeof(submenu)=NULL) doerror(System error); Mb-mpoint-tail-next-before=Mb-mpoint-tail; Mb-mpoint-tail=Mb-

10、mpoint-tail-next; if(strlen(itemtitle)Mb-mpoint-subwidth) Mb-mpoint-subwidth=strlen(itemtitle); /*該語句主要計(jì)算一下剛加進(jìn)來的菜單項(xiàng)的字符數(shù),如果比菜單的寬度還要大,則把該寬度賦值給subwidth,主要是為了畫菜單是寬度足夠*/ Mb-mpoint-subcount+;/*菜單項(xiàng)數(shù)目加一*/ Mb-mpoint-tail-number=Mb-mpoint-subcount; Mb-mpoint-tail-isactive=0; Mb-mpoint-tail-content=itemtitle;

11、Mb-mpoint-tail-next=NULL; 3. 繪畫菜單欄void drawmenu() Mb-mpoint=Mb-mhead; rectangle(0,0,getmaxx()-1,Mb-y+Mb-barheight);/*畫一個(gè)方框*/ while(Mb-mpoint!=NULL)outtextxy(Mb-mpoint-number*Mb-baritemwidth+Mb-x+5,Mb-y+6,Mb-mpoint-content); /*在菜單欄中逐項(xiàng)畫出菜單的內(nèi)容*/Mb-mpoint=Mb-mpoint-next;4. 繪畫當(dāng)前激活的菜單void drawsubmenu()sub

12、menu *temp;int x; /*x記錄當(dāng)前畫菜單的x位置*/x=Mb-mpoint-number*Mb-baritemwidth+Mb-x;temp=Mb-mpoint-head;copyimage(x,Mb-barheight+2,x+Mb-mpoint-subwidth*8+5,(Mb-mpoint-subcount+1)*Mb-barheight+3); /*保存繪畫區(qū)的內(nèi)容,copyimage為自寫的函數(shù)*/setfillstyle(1,getbkcolor();bar(x,Mb-barheight+2,x+Mb-mpoint-subwidth*8+5,(Mb-mpoint-s

13、ubcount+1)*Mb-barheight+3); /*用背景色把繪畫區(qū)覆蓋一下*/rectangle(x,Mb-barheight+2,x+Mb-mpoint-subwidth*8+5,(Mb-mpoint-subcount+1)*Mb-barheight+3); /*畫一個(gè)方框*/while(temp!=NULL)if(temp-isactive) /*如果是當(dāng)前激活的菜單,則畫一個(gè)紅色方框背景*/setfillstyle(1,RED);bar(x+2,temp-number*Mb-barheight+4,x+Mb-mpoint-subwidth*8+3,(temp-number+1)

14、*Mb-barheight-1);outtextxy(x+5,temp-number*Mb-barheight+5,temp-content);temp=temp-next;4. 進(jìn)入菜單/*根據(jù)menu指定的字符串,說明用戶從哪項(xiàng)菜單進(jìn)入菜單,如gotomenucur(”File”)說明用戶激活了“File”菜單*/void gotomenucur(char *menu)Mb-mpoint=Mb-mhead;while(Mb-mpoint-next!=NULL)if(stricmp(Mb-mpoint-content,menu)=0)break;Mb-mpoint=Mb-mpoint-nex

15、t;Mb-mpoint-sub=Mb-mpoint-head;Mb-mpoint-sub-isactive=1;drawsubmenu();5. 菜單按鍵處理void menukey()int key;while(1)key=get_key();switch(key)case KEY_LEFT: /*說明用戶按下了向左按鍵,Mb-mpoint應(yīng)該向前移一項(xiàng)*/Mb-mpoint-sub-isactive=0;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);if(Mb-mpoint-before!=NULL) /*如

16、果當(dāng)前已經(jīng)是mhead了,應(yīng)該指向mtail*/Mb-mpoint=Mb-mpoint-before;elseMb-mpoint=Mb-mtail;Mb-mpoint-sub=Mb-mpoint-head;Mb-mpoint-sub-isactive=1;drawsubmenu();/*重畫菜單,跳出*/break;case KEY_RIGHT: /*說明用戶按下了向右鍵,解釋同KEY_LEFT*/Mb-mpoint-sub-isactive=0;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);if(Mb-mpoi

17、nt-next!=NULL)Mb-mpoint=Mb-mpoint-next;elseMb-mpoint=Mb-mhead;Mb-mpoint-sub=Mb-mpoint-head;Mb-mpoint-sub-isactive=1;drawsubmenu();break;case KEY_UP: /*說明用戶按下了向上鍵,應(yīng)把當(dāng)前激活的菜單項(xiàng)向上移一項(xiàng)*/Mb-mpoint-sub-isactive=0;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);if(Mb-mpoint-sub-before!=NULL)Mb

18、-mpoint-sub=Mb-mpoint-sub-before;elseMb-mpoint-sub=Mb-mpoint-tail;Mb-mpoint-sub-isactive=1;drawsubmenu();break;case KEY_DOWN: /*說明用戶按下了向下鍵,當(dāng)前菜單項(xiàng)應(yīng)向下移一項(xiàng)*/Mb-mpoint-sub-isactive=0;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);if(Mb-mpoint-sub-next!=NULL)Mb-mpoint-sub=Mb-mpoint-sub-nex

19、t;elseMb-mpoint-sub=Mb-mpoint-head;Mb-mpoint-sub-isactive=1;drawsubmenu();break;case ENTER: /*說明用戶按下了回車鍵,調(diào)用Mb-docommand()*/Mb-mpoint-sub-isactive=0;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);Mb-docommand();return;case ESC: /*說明用戶按下了退出鍵,把拷貝的屏幕區(qū)域放回,不作任何處理*/Mb-mpoint-sub-isactive=0

20、;backimage(Mb-mpoint-number*Mb-baritemwidth+Mb-x,Mb-barheight+2);return;游標(biāo)與滾屏l 思想在屏幕上顯示的是兩個(gè)隊(duì)列,一個(gè)是等待隊(duì)列,一個(gè)是就緒隊(duì)列。設(shè)置了一個(gè)游標(biāo),可以用上下鍵移動(dòng)指向每個(gè)進(jìn)程,然后對(duì)指向進(jìn)程進(jìn)行各種操作,包括掛起,解掛,刪除。我設(shè)置的屏幕上最多只能顯示12個(gè)進(jìn)程,就緒最多6個(gè),等待最多6個(gè),那么當(dāng)進(jìn)程多于此數(shù)時(shí),在用戶按上下鍵時(shí),應(yīng)該有滾屏功能。滾屏的思想如下:假設(shè)有就緒隊(duì)列里有N1個(gè)進(jìn)程,每個(gè)進(jìn)程編號(hào)1,2,3.N1-1,N1。等待隊(duì)列中有N2個(gè)進(jìn)程,每個(gè)進(jìn)程編號(hào)1,2,3N2-1,N2。假設(shè)當(dāng)前游標(biāo)指

21、向的進(jìn)程編號(hào)小于6,則繪畫1到6個(gè)進(jìn)程(如果進(jìn)程數(shù)小于6則畫出所有進(jìn)程),如果當(dāng)前游標(biāo)指向的進(jìn)程編號(hào)為N(N6),則繪畫N6到N個(gè),這樣就實(shí)現(xiàn)了滾屏。當(dāng)當(dāng)前游標(biāo)位置位于就緒隊(duì)列結(jié)尾,則當(dāng)用戶按下向下按鍵時(shí),應(yīng)該將游標(biāo)移動(dòng)到等待隊(duì)列的第一個(gè);當(dāng)當(dāng)前游標(biāo)位置位于就緒隊(duì)列第一個(gè),則當(dāng)用戶按下向上按鍵時(shí),應(yīng)該移動(dòng)到等待隊(duì)列最后一個(gè);同理,當(dāng)當(dāng)前游標(biāo)位于等待隊(duì)列隊(duì)尾對(duì)首時(shí),應(yīng)移動(dòng)就緒隊(duì)列隊(duì)首隊(duì)尾。l 函數(shù)實(shí)現(xiàn)因?yàn)槲野训却?duì)列和就緒隊(duì)列放在同一個(gè)鏈表里,所以要實(shí)現(xiàn)上面的功能可能有點(diǎn)problem,但多用幾個(gè)函數(shù)就能實(shí)現(xiàn)。1. /*這個(gè)函數(shù)用來給每個(gè)進(jìn)程編號(hào)*/void updateprocess()int

22、 i=1,j=1;process *temp;temp=phead;while(temp)if(temp-isrun) /*給就緒隊(duì)列中的進(jìn)程編號(hào)*/temp-pos=i+;else /*給等待隊(duì)列中的進(jìn)程編號(hào)*/temp-pos=j+;temp=temp-next;2. /*這個(gè)函數(shù)用來得到列表中就緒隊(duì)列中的第一個(gè)*/process *getfirstrun() process *temp; if(!phead) return NULL; temp=phead; while(temp!=NULL) if(temp-isrun) /*找到第一個(gè),就跳出循環(huán)*/ break; temp=temp

23、-next; return temp-isrun?temp:NULL; /*如果找到就返回,否則就返回NULL,因?yàn)榭赡艽嬖谖ㄒ灰粋€(gè)等待隊(duì)列中的*/ 3. /*該函數(shù)用來獲取列表中就緒隊(duì)列中的最后一個(gè)*/ process *gettailrun() process *temp; if(!ptail) /*如果列表為空,則返回NULL*/ return NULL; temp=ptail; /*從列表尾部開始找*/ while(temp!=NULL) if(temp-isrun) /*如果找到,就跳出循環(huán)*/ break; temp=temp-before; return temp-isrun?t

24、emp:NULL; /*判斷找到的是不是就緒隊(duì)列中的如果不是就返回NULL,因?yàn)榭赡艽嬖谥挥幸粋€(gè)等待隊(duì)列中的*/ 4. /*這個(gè)函數(shù)用來找相對(duì)于p的下一個(gè)就緒隊(duì)列中的進(jìn)程*/ process *getnextrun(process *p) process *temp; if(!p) return NULL; temp=p-next; while(temp!=NULL) if(temp-isrun) /*如果找到,就跳出循環(huán)*/ break; temp=temp-next; return temp; 5. /*這個(gè)函數(shù)用來找相對(duì)于p的前一個(gè)就緒隊(duì)列中的進(jìn)程*/ process *getbefor

25、erun(process *p) process *temp; if(!p) return NULL; temp=p-before; while(temp!=NULL) if(temp-isrun) break; temp=temp-before; return temp; 6. /*這個(gè)函數(shù)用來找等待隊(duì)列中的第一個(gè),一下三個(gè)函數(shù)原理跟就緒隊(duì)列中的操作函數(shù)一樣,只是把查找的條件改成!temp-isrun*/ process *getfirstready() process *temp; if(!phead) return NULL; temp=phead; while(temp!=NULL)

26、if(!temp-isrun) break; temp=temp-next; return temp-isrun?NULL:temp; 7. process *gettailready() process *temp; if(!ptail) return NULL; temp=ptail; while(temp!=NULL) if(!temp-isrun) break; temp=temp-before; return temp-isrun?NULL:temp; 8. process *getnextready(process *p) process *temp; if(!p) return

27、NULL; temp=p-next; while(temp!=NULL) if(!temp-isrun) break; temp=temp-next; return temp; 9. process *getbeforeready(process *p) process *temp; if(!p) return NULL; temp=p-before; while(temp!=NULL) if(!temp-isrun) break; temp=temp-before; return temp; 10. /*這個(gè)函數(shù)用來得到下一個(gè)游標(biāo)的位置*/void getnext() process *te

28、mp; if(phead=ptail)/*如果鏈表中只有一個(gè)進(jìn)程,則什么也不處理,返回*/ ppoint=phead; return; if(ppoint=gettailrun()/*如果當(dāng)前游標(biāo)位置是就緒隊(duì)列中的最后一個(gè)*/ temp=getfirstready();/*則指向第一個(gè)等待隊(duì)列*/ ppoint=temp?temp:getfirstrun(); else if(ppoint=gettailready()/*如果當(dāng)前游標(biāo)位置是等待隊(duì)列中的最后一個(gè)*/ temp=getfirstrun();/*則指向就緒隊(duì)列中的第一個(gè)*/ ppoint=temp?temp:getfirstread

29、y(); else if(ppoint-isrun) /*如果當(dāng)前隊(duì)列在就緒隊(duì)列中移動(dòng)*/ ppoint=getnextrun(ppoint); /*移向就緒隊(duì)列中的下一個(gè)*/ else ppoint=getnextready(ppoint); /*移向等待隊(duì)列中的下一個(gè)*/ 11. /*這個(gè)函數(shù)用來得到上一個(gè)游標(biāo)的位置,基本的解釋同getnext()差不多*/ void getbefore() process *temp;if(phead=ptail) ppoint=phead;return; if(ppoint=getfirstrun() temp=gettailready(); ppoi

30、nt=temp?temp:gettailrun(); else if(ppoint=getfirstready() temp=gettailrun(); ppoint=temp?temp:gettailready(); else if(ppoint-isrun) ppoint=getbeforerun(ppoint); else ppoint=getbeforeready(ppoint); 12. /*按鍵處理函數(shù)*/void key_U_D(int key)switch(key)case KEY_DOWN:if(!phead) ppoint=NULL;else getnext();break

31、;/*如果按下的是向下鍵*/case KEY_UP:if(!ptail) ppoint=NULL;else getbefore();break; /*如果按下的是向上鍵*/if(ppoint) /*drawl_r(int,int)這個(gè)函數(shù)根據(jù)傳遞進(jìn)來的兩個(gè)參數(shù)指明應(yīng)該畫的起始編號(hào)*/if(ppoint-pos6)if(ppoint-isrun)drawl_r(ppoint-pos-6,0);else drawl_r(0,ppoint-pos-6);else drawl_r(0,0);else drawl_r(0,0);獲取用戶按鍵C語言庫(kù)函數(shù)提供的getch(),或bioskey()在處理字符

32、和菜單輸入時(shí)有點(diǎn)麻煩,改寫了一個(gè)函數(shù)int get_key() union REGS rg; rg.h.ah=0; int86(0x16,&rg,&rg); if(rg.h.al=0)/*說明按下了修飾鍵,把這個(gè)值左移8位*/return rg.h.ah=48&key=57|key=8) /*如果按下的是數(shù)字鍵或者是退格鍵*/if(key=8) /*如果是退格鍵,就用背景色把原來的字符畫一遍,相當(dāng)于覆蓋,然后去掉結(jié)尾一個(gè),用前景色畫字符,就相當(dāng)于刪掉一個(gè)字符(實(shí)際上也刪掉了)*/color=getcolor();setcolor(getbkcolor();outtextxy(x+10,y+20

33、,strcat(desc,number);setcolor(color);number-i=0; /*這句相當(dāng)于刪掉一個(gè)字符*/else if(ipos6) /*因?yàn)槊總€(gè)隊(duì)列最多只能顯示6個(gè)隊(duì)列,所以當(dāng)當(dāng)前光標(biāo)指向的進(jìn)程的pos6時(shí),pos一定是底部pos=6;else pos=ppoint-pos;bar(1-ppoint-isrun)*450,(pos-1)*50+80,(1-ppoint-isrun)*450+15,(pos-1)*50+85);/*畫一個(gè)游標(biāo)if(stop) /*stop是全局變量(為這是一個(gè)模擬程序,所以當(dāng)用戶想暫停或者什么的,可以暫停)果stop是true,則什么事

34、都不做return;i=getnum(1); /*獲取就緒隊(duì)列中的進(jìn)程總數(shù)*/j=getnum(0); /*獲取等待隊(duì)列中的進(jìn)程總數(shù)*/if(i+j)=0) /*如果兩個(gè)隊(duì)列為空*/stop=1;fresh();/*刷新一下屏幕*/return;if(i0&canrun) /*如果就緒隊(duì)列中的進(jìn)程數(shù)小于maxrun(maxrun為就緒隊(duì)列中的最大數(shù)目)且等待隊(duì)列不為空,且有足夠的內(nèi)存(maxrun為true時(shí)表示有足夠內(nèi)存)*/getfromeready();/*從等待隊(duì)列中選取一個(gè)優(yōu)先級(jí)最高,時(shí)間最少的*/coverfront();/*把游標(biāo)重畫一遍(這里放這個(gè)函數(shù)好像有點(diǎn)多余)*/gett

35、ime(&t2);time=(t2.ti_hour-t1.ti_hour)*60*60*100+(t2.ti_min-t1.ti_min)*60*100+(t2.ti_sec-t1.ti_sec)*100+t2.ti_hund-t1.ti_hund; /*計(jì)算兩次執(zhí)行handle的時(shí)間差,其實(shí)可以用gettime()這個(gè)庫(kù)函數(shù),但當(dāng)時(shí)沒發(fā)現(xiàn)。*/runtime-=time; /*runtime是時(shí)間片大小,是個(gè)全局變量*/drawsector();/*畫屏幕中間的時(shí)間片轉(zhuǎn)盤*/if(runtimeisrun)*screenweidth,這樣,如果它是就緒隊(duì)列中的(它的isrun是1),它就在屏

36、幕的左邊,如果它是等待隊(duì)列中的(它的isrun是0),它就在屏幕的右邊。關(guān)于集成圖形驅(qū)動(dòng)做成exe文件在tc里頭,生成的exe文件如果是文本模式的,則可以運(yùn)行,而如果是圖形模式的,生成的exe老是提示你沒有初始化圖形驅(qū)動(dòng),可以把圖形驅(qū)動(dòng)集成到graphic里頭,方法如下:注冊(cè)圖形驅(qū)動(dòng):bgiobj EGAVGA 回車得到EGAVGA.OBJTLIB LIBGRAPHICS.LIB+EGAVGA.OBJ回車即可在程序中用registerbgidriver(EGAVGA_driver);其它對(duì)應(yīng)的如下CAG.BGI CGA_driverEGA.VGA.BGI EGAVGA_driverHERC.B

37、GIHERC_driverATT.BGIATT_driverPC3270.BGIPC3270_driverIBM8514.BGIIBM8514_driver注冊(cè)字體:bgiobj trip|litt|sans|goth分別對(duì)應(yīng)字體trip.chr|litt.chr|sans.chr|goth.chrtlib libgraphics.lib+litt.obj字型驅(qū)動(dòng)registerbgifont()litt.chrtlib得到的字符名入samll_font源程序:#include #include #include #include #include #include #include /*包含

38、一些必要的頭文件*/#define INTR 0X1C/*定義時(shí)鐘中斷號(hào)*/#define ENTER 13/*定義回車鍵*/#define KEY_UP 18432/*定義向上鍵的整數(shù)值*/#define KEY_DOWN 20480/*定義向下鍵的整數(shù)值*/#define KEY_LEFT 19200/*定義向左鍵的整數(shù)值*/#define KEY_RIGHT 19712/*定義向右鍵的整數(shù)值*/#define ALT_F 8448/*定義按下altf返回的整數(shù)值*/#define ALT_S 7936/*定義按下alts返回的整數(shù)值*/#define ALT_O 6144/*定義alto

39、返回的整數(shù)值*/#define ALT_H 8960/*定義alth返回的整數(shù)值*/#define ESC 27/*定義esc返回的整數(shù)值,以上這些鍵值都是有g(shù)et_key()函數(shù)獲得*/typedef struct menubar_sint number,x,y,barheight,baritemwidth;struct menu_s *mhead;struct menu_s *mtail;struct menu_s *mpoint;void (* docommand)();MenuBar; /*定義一個(gè)菜單欄數(shù)據(jù)結(jié)構(gòu),在上面已經(jīng)解釋過*/typedef struct menu_sint n

40、umber;int subwidth;int subcount;char *content;struct menu_s *next;struct menu_s *before;struct submenu_s *sub;struct submenu_s *head;struct submenu_s *tail;Menu; /*定義一個(gè)菜單結(jié)構(gòu)體,具體在上面已經(jīng)解釋過*/typedef struct submenu_sint number;int isactive;char *content;struct submenu_s *next;struct submenu_s *before;subm

41、enu; /*定義一個(gè)菜單項(xiàng),具體已在上面解釋過*/typedef struct process_tint pid;int isrun;int ishalt;int pos;int priority;int time_total;int time_left;long startaddr;long size;void (*fun)();struct process_t *next;struct process_t *before;process; /*定義一個(gè)pcb,在上面已經(jīng)解釋過*/typedef struct memory_tlong startaddr;long size;struct

42、memory_t *next;struct memory_t *before;memory; /*定義一個(gè)空閑內(nèi)存塊結(jié)構(gòu),在上面已經(jīng)解釋過*/void docommand();void drawprocess(process *,int,int,int,int);void readfile();void writefile();void drawl_r(int,int);void addprocess();long getinput(char *);void savefile();void fresh();int findm_f_f(process *p);int findm_b_f(proc

43、ess *p);long getfreesize();void acceptm_f_f(process *p);void drawmembar();void creatememory(long,long);void rancreatep(long num);void randomcreate();void setmemsize();/*一些函數(shù)聲明,一下開始定義全局變量*/MenuBar *Mb; /*一個(gè)菜單欄*/void *buff; /*用來保存畫菜單時(shí)預(yù)先保存的區(qū)域*/process *phead,*ptail,*prunning,*ppoint; /*用來保存進(jìn)程隊(duì)列的頭,尾,正在運(yùn)

44、行,和當(dāng)前游標(biāo)指向的一個(gè)進(jìn)程*/struct time t1,t2; /*定義兩個(gè)time結(jié)構(gòu)體類型,用來記錄在兩次handle函數(shù)執(zhí)行之間的時(shí)間差*/memory *mhead,*mtail; /*空閑內(nèi)存塊的頭尾指針*/int roundtime=500,runtime=500,maxrun=5,stop=1,canrun=1,memway=1; /*roundtime用來保存時(shí)間片大小,runtime用來保存當(dāng)前時(shí)間片大小,maxrun用來保存系統(tǒng)所能運(yùn)行的最大進(jìn)程數(shù),stop用來控制是否停止模擬,canrun用來記錄系統(tǒng)是否有足夠內(nèi)存,memway用來記錄當(dāng)前內(nèi)存的適應(yīng)方式(最佳適應(yīng)還

45、是最先適應(yīng))*/long memorysize=35460L; /*用來定義內(nèi)存大小*/int get_key() union REGS rg; rg.h.ah=0; int86(0x16,&rg,&rg); if(rg.h.al=0)return rg.h.ahnumber=0;Mb-mpoint=Mb-mhead=Mb-mtail=NULL;Mb-x=0;Mb-y=0;Mb-barheight=18;Mb-baritemwidth=100;Mb-docommand=docommand; /*初始化Mb中的一些變量,具體的變量含義已在上面解釋過*/if(Mb-mtail=NULL) /*如果當(dāng)

展開閱讀全文
溫馨提示:
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. 裝配圖網(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ì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!