存儲(chǔ)管理---動(dòng)態(tài)分區(qū)分配算法的模擬(共27頁)_第1頁
存儲(chǔ)管理---動(dòng)態(tài)分區(qū)分配算法的模擬(共27頁)_第2頁
存儲(chǔ)管理---動(dòng)態(tài)分區(qū)分配算法的模擬(共27頁)_第3頁
存儲(chǔ)管理---動(dòng)態(tài)分區(qū)分配算法的模擬(共27頁)_第4頁
存儲(chǔ)管理---動(dòng)態(tài)分區(qū)分配算法的模擬(共27頁)_第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上一、設(shè)計(jì)任務(wù) 完成存儲(chǔ)器動(dòng)態(tài)分區(qū)分配算法的模擬實(shí)現(xiàn)。二、設(shè)計(jì)思想 在對(duì)數(shù)據(jù)結(jié)構(gòu)有一定掌握程度的情況下設(shè)計(jì)合理的數(shù)據(jù)結(jié)構(gòu)來描述存儲(chǔ)空間,實(shí)現(xiàn)分區(qū)存儲(chǔ)管理的內(nèi)存分配功能,應(yīng)該選擇最合適的適應(yīng)算法(首次適應(yīng)算法,最佳適應(yīng)算法,最后適應(yīng)算法,最壞適應(yīng)算法),實(shí)現(xiàn)分區(qū)存儲(chǔ)管理的內(nèi)存回收算法,在這些存儲(chǔ)管理中間必然會(huì)有碎片的產(chǎn)生,當(dāng)碎片產(chǎn)生時(shí),進(jìn)行碎片的拼接,等等相關(guān)的內(nèi)容。三、預(yù)期目的讓我們了解操作系統(tǒng)的基本概念,理解計(jì)算機(jī)系統(tǒng)的資源如何組織,操作系統(tǒng)如何有效地管理這些系統(tǒng)資源,用戶如何通過操作系統(tǒng)與計(jì)算機(jī)系統(tǒng)打交道。通過課程設(shè)計(jì),我們可以進(jìn)一步理解在計(jì)算機(jī)系統(tǒng)上運(yùn)行的其它各類

2、操作系統(tǒng),并懂得在操作系統(tǒng)的支持下建立自己的應(yīng)用系統(tǒng)。操作系統(tǒng)課程設(shè)計(jì),對(duì)于訓(xùn)練學(xué)生掌握程序設(shè)計(jì)、熟悉上機(jī)操作和程序調(diào)試技術(shù)都有重要作用。重點(diǎn)培養(yǎng)學(xué)生的思維能力、設(shè)計(jì)能力、創(chuàng)新能力和排錯(cuò)能力。四、設(shè)計(jì)方案 首先是對(duì)相關(guān)知識(shí)的掌握,例如數(shù)據(jù)結(jié)構(gòu),計(jì)算方法,組成原理以及操作系統(tǒng)等。在這些基本知識(shí)的基礎(chǔ)上進(jìn)行擴(kuò)展,用語言的形式從函數(shù),數(shù)據(jù)結(jié)構(gòu)原代碼,原程序等方面來達(dá)到自己想要的目的。該設(shè)計(jì)就是要達(dá)到對(duì)各個(gè)細(xì)節(jié)的問題的解決將各個(gè)數(shù)據(jù)塊連接起來,最終達(dá)到存儲(chǔ)器動(dòng)態(tài)分區(qū)分配算法的模擬實(shí)現(xiàn)。五、數(shù)據(jù)結(jié)構(gòu)1 設(shè)計(jì)合理的數(shù)據(jù)結(jié)構(gòu)來描述存儲(chǔ)空間:1) 對(duì)于未分配出去的部分,用空閑分區(qū)鏈表來描述。struct fr

3、eeList int startAddress; /* 分區(qū)起始地址 */int size; /* 分區(qū)大小 */struct freeList *next; /* 分區(qū)鏈表指針 */ 2) 對(duì)于已經(jīng)分配出去的部分,由裝入內(nèi)存的作業(yè)占據(jù)。struct usedList int startAddress; /* 分區(qū)起始地址 */int jobID; /* 分區(qū)中存放作業(yè)ID */struct usedList *next; /* 分區(qū)鏈表指針 */3) 將作業(yè)組織成鏈表。struct jobListint id; /* 作業(yè)ID */int size; /* 作業(yè)大?。ㄐ枰拇鎯?chǔ)空間大小) *

4、/int status; /* 作業(yè)狀態(tài) 0 : new job ,1 : in the memory , 2 : finished . */struct jobList *next; /* 作業(yè)鏈表指針 */以上將存儲(chǔ)空間分為空閑可占用兩部分,在usedlist中設(shè)jobID而不設(shè)size,可以在不增加空間復(fù)雜度(與freelist相比)的同時(shí)更方便的實(shí)現(xiàn)可變分區(qū)存儲(chǔ)管理(從后面的一些函數(shù)的實(shí)現(xiàn)上可以得出這個(gè)結(jié)論)。盡管設(shè)置joblist增加了空間復(fù)雜度,但它的存在,使得該程序可以方便的直接利用D盤中的JOB文件。該文件可以認(rèn)為是一個(gè)和其他進(jìn)程共享的資源。通過這個(gè)文件,其他進(jìn)程寫入數(shù)據(jù)供讀取

5、。這中思想在操作系統(tǒng)設(shè)計(jì)中體現(xiàn)的很多。2 實(shí)現(xiàn)分區(qū)存儲(chǔ)管理的內(nèi)存分配功能,選擇適應(yīng)算法(首次適應(yīng)算法,最佳適應(yīng)算法,最后適應(yīng)算法,最壞適應(yīng)算法)?;驹矸治觯?1) Best fit :將空閑分區(qū)按大小從小到大排序,從頭找到大小合適的分區(qū)。2) Worst fit:將空閑分區(qū)按大小從大到小排序,從頭找到大小合適的分區(qū)。3) First fit :將空閑分區(qū)按起始地址大小從小到大排序,4) Last fit :將空閑分區(qū)按起始地址大小從大到小排序,由此,可將空閑分區(qū)先做合適的排序后用對(duì)應(yīng)的適應(yīng)算法給作業(yè)分配存儲(chǔ)空間。排序函數(shù) order(bySize為零則按分區(qū)大小排序,否則按分區(qū)起始地址;i

6、nc為零從小到大排序,否則從大到小排序;通過empty指針返回結(jié)果)。void order(struct freeList *empty,int bySize,int inc)struct freeList *p,*q,*temp;int startAddress,size;for(p = (*empty) -> next;p;p = p -> next) /* 按bySize和inc兩個(gè)參數(shù)尋找合適的節(jié)點(diǎn),用temp指向它 */for(temp = q = p;q;q = q -> next)switch(bySize)case 0 : switch(inc)case 0:

7、if(q->size < temp->size)temp = q;break;default:if(q->size > temp->size)temp = q;break; break;default: switch(inc)case 0:if(q->startAddress < temp->startAddress)temp = q;break;default:if(q->startAddress > temp->startAddress)temp = q;break; break; /* 交換節(jié)點(diǎn)的成員值 */ if(

8、temp != p) startAddress = p->startAddress;size = p->size;p->startAddress = temp->startAddress;p->size = temp->size;temp->startAddress = startAddress;temp->size = size;3 實(shí)現(xiàn)分區(qū)存儲(chǔ)管理的內(nèi)存回收算法。void insertFreeNode(struct freeList *empty,int startAddress,int size)插入回收的空節(jié)點(diǎn)分區(qū),處理回收分區(qū)與空閑分區(qū)

9、的四種鄰接關(guān)系。struct freeList *p,*q,*r; for(p = *empty;p -> next;p = p -> next) ; /* 處理鏈表尾部的鄰接情況 */if(p = *empty | p -> startAddress + p -> size < startAddress)/* 與尾部不相鄰*/makeFreeNode(&r,startAddress,size); /* 通過r指針返回創(chuàng)建的空閑節(jié)點(diǎn)*/r -> next = p -> next; /* 插入獨(dú)立的空閑節(jié)點(diǎn) */p -> next = r;

10、return ;if(p -> startAddress + p -> size = startAddress) /* 與尾部上鄰 */p -> size += size; /* 合并尾部節(jié)點(diǎn) */return ;q = (*empty) -> next; /* 處理鏈表首節(jié)點(diǎn)的鄰接情況 */if(startAddress + size = q -> startAddress) /* 與首節(jié)點(diǎn)下鄰 */q -> startAddress = startAddress; /* 合并首節(jié)點(diǎn) */q -> size += size;else if(start

11、Address + size < q -> startAddress) /* 與首節(jié)點(diǎn)不相鄰 */makeFreeNode(&r,startAddress,size);r -> next = (*empty) -> next;(*empty) -> next = r;else /* 處理鏈表中間的鄰接情況 */while(q -> next && q -> startAddress < startAddress)p = q;q = q -> next;if(p -> startAddress + p ->

12、 size = startAddress && q -> startAddress = startAddress + size) /* 上下鄰,合并節(jié)點(diǎn) */p -> size += size + q -> size;p -> next = q -> next;free(q); /* 刪除多余節(jié)點(diǎn) */else if(p -> startAddress + p -> size = startAddress && q -> startAddress != startAddress + size) /*上鄰,增加節(jié)點(diǎn)的

13、大小*/p -> size += size;else if(p -> startAddress + p -> size != startAddress && q -> startAddress = startAddress + size) /* 下鄰 */q -> startAddress = startAddress; /* 修改節(jié)點(diǎn)起始地址 */q -> size += size; /* 修改節(jié)點(diǎn)的大小 */else /* 上下不相鄰 */makeFreeNode(&r,startAddress,size);r -> nex

14、t = p -> next;p -> next = r;4 當(dāng)碎片產(chǎn)生時(shí),進(jìn)行碎片的拼接。void moveFragment(struct jobList *jobs,struct freeList *empty,struct usedList *used)int size,status;struct usedList *p;int address = memoryStartAddress; /*全局變量,初始化時(shí)分配存儲(chǔ)空間始址*/if(*empty)->next = NULL) /* 空閑分區(qū)鏈表為空,提示并返回 */printf("nThe memory wa

15、s used out at all.nMay be you should finish some jobs first or press any key to try again !");getch();return;for(p = (*used) -> next;p;p = p-> next)/* 循環(huán)的修改占用分區(qū)的始址 */p -> startAddress = address;getJobInfo(jobs,p -> jobID,&size,&status); /* 由作業(yè)ID獲得作業(yè)大小 */address += size;(*emp

16、ty)->next->startAddress = address;/*修改空閑分區(qū)的首節(jié)點(diǎn)始址、大小*/(*empty) -> next -> size = memorySize - (address - memoryStartAddress);(*empty) -> next -> next = NULL; /* 刪除首節(jié)點(diǎn)后的所有節(jié)點(diǎn) */5 空閑分區(qū)隊(duì)列顯示:int showFreeList(struct freeList *empty)6 作業(yè)占用鏈表顯示:int showUsedList(struct jobList *jobs,struct u

17、sedList *used) 從頭到尾顯示used鏈,同時(shí)通過其中的作業(yè)ID在jobs中查對(duì)應(yīng)的大小。7 從鍵盤輸入作業(yè)到D盤的JOB文件:void inputJob(void)8 從JOB文件中讀出作業(yè)并創(chuàng)建作業(yè)鏈表:int makeJobList(struct jobList *jobs)9 顯示作業(yè)鏈表:int showJobList(struct jobList *jobs) 10.更新作業(yè)鏈表中作業(yè)的狀態(tài): int updateJobFile(struct jobList *jobs)11.根據(jù)作業(yè)鏈表更新JOB文件: int updateJobFile(struct jobList

18、 *jobs) 12.為作業(yè)分配存儲(chǔ)空間、狀態(tài)必須為0:int allocate(struct freeList *empty,int size) 13.結(jié)束一個(gè)作業(yè)號(hào)為id的作業(yè),釋放存儲(chǔ)空間(由*startAddress返回空間的起始地址):int finishJob(struct usedList *used,int id,int *startAddress)14.插入釋放的空間到used鏈表中(作業(yè)號(hào)為id,startAddress由函數(shù)13返回):void insertUsedNode(struct usedList *used,int id,int startAddress)15.

19、獲取作業(yè)的信息: void getJobInfo(struct jobList *jobs,int id,int *size,int *status)16.初始化存儲(chǔ)空間起始地址、大?。簐oid iniMemory(void)17.選擇適應(yīng)算法:char selectFitMethod(void)18.根據(jù)參數(shù)startAddress、size創(chuàng)建空閑節(jié)點(diǎn),由empty指針返回:void makeFreeNode(struct freeList *empty,int startAddress,int size)19.以要求的方式打開文件:void openFile(FILE *fp,char

20、*filename,char *mode)20.出現(xiàn)嚴(yán)重錯(cuò)誤時(shí)顯示信息并結(jié)束程序;void errorMessage(void)六、算法流程1、Dynamic Zonal Memory Management其中1、Initializiation.按順序利用了openFile()、iniMemory()、makeFreeNode()、inputJob()(選擇利用D盤JOB文件時(shí)提供作業(yè)信息)、makeJobList()、allocate()、insertUsedNode()(選擇利用D盤JOB文件時(shí)先將狀態(tài)為1的作業(yè)放到存儲(chǔ)空間中,以恢復(fù)上次的模擬實(shí)驗(yàn),或使本次模擬時(shí)不出錯(cuò))selectFit

21、Method()等自編函數(shù)。2、Put job into memory(allocate memory)按順序利用了showJobList()(選手動(dòng)逐個(gè)為作業(yè)分配存儲(chǔ)空間時(shí))、openFile()、order()、allocate()、errorMessage()、insertUsedNode()、updateJobStatus()updateJobFile()函數(shù) 3、Finish job(reuse memory)按順序利用了openFile()、showUsedList()、getJobInfo()、insert FreeNode()、updateJobStatus()、updateJ

22、obFile()、errorMessage()等自編函數(shù)。 4、Show current free list 按順序利用了openFile()、showFreeList()函數(shù)。 5、Show current memory used by jobs按順序利用了openFile()、showUsedList()函數(shù)。 6、Move fragment together按順序利用了openFile()、moveFragment()函數(shù)。7、Exit按順序利用了openFile()、exit(0)函數(shù)。七、程序清單 1、原程序#include<stdio.h>#include<tim

23、e.h>#include<stdlib.h>int memoryStartAddress = -1;int memorySize = -1;struct jobListint id; /* 作業(yè)ID */int size; /* 作業(yè)大小(需要的存儲(chǔ)空間大小) */int status; /* 作業(yè)狀態(tài) 0 : new job ,1 : in the memory , 2 : finished . */struct jobList *next; /* 作業(yè)鏈表指針 */;struct freeListint startAddress; /* 分區(qū)起始地址 */int size

24、; /* 分區(qū)大小 */struct freeList *next; /* 分區(qū)鏈表指針 */;struct usedList int startAddress; /* 分區(qū)起始地址 */int jobID; /* 分區(qū)中存放作業(yè)ID */struct usedList *next; /* 分區(qū)鏈表指針 */;void errorMessage(void) /*出現(xiàn)嚴(yán)重錯(cuò)誤時(shí)顯示信息并結(jié)束程序*/printf("ntError !a");printf("nPress any key to exit !");getch();exit(1);void ope

25、nFile(FILE *fp,char *filename,char *mode) /*以要求的方式打開文件*/if(*fp = fopen(filename,mode) = NULL)printf("nCan't open %s in mode %s.",filename,mode);errorMessage();void makeFreeNode(struct freeList *empty,int startAddress,int size) /*根據(jù)參數(shù)startAddress、size創(chuàng)建空閑節(jié)點(diǎn),由empty指針返回*/if(*empty = mallo

26、c(sizeof(struct freeList) = NULL)printf("nNot enough to allocate for the free node .");errorMessage();(*empty)->startAddress = startAddress;(*empty)->size = size;(*empty)->next = NULL;void iniMemory(void) /*初始化存儲(chǔ)空間起始地址、大小*/char MSA10,MS10;printf("nPlease input the start addre

27、ss of the memory !");scanf("%s",MSA);memoryStartAddress = atoi(MSA);printf("nPlease input the size of the memory !");scanf("%s",MS);memorySize = atoi(MS);char selectFitMethod(void) /*選擇適應(yīng)算法*/FILE *fp;char fitMethod;doprintf("nnPlease input a char as fallow to

28、select the fit method !n 1 (Best fit) n 2 (Worst fit) n 3 (First fit) n 4 (Last fit)n");fitMethod = getche();while(fitMethod < '1' | fitMethod > '4'); openFile(&fp,"d:result.cl","a");switch(fitMethod)case '1': fprintf(fp,"nnnntBest fit&

29、quot;); fprintf(fp,"n*"); break;case '2': fprintf(fp,"nnnntWorst fit"); fprintf(fp,"n*"); break;case '3': fprintf(fp,"nnnntFirst fit"); fprintf(fp,"n*"); break;case '4': fprintf(fp,"nnnntLast fit"); fprintf(fp,"

30、n*"); break;fclose(fp);return fitMethod;void inputJob(void) /*從鍵盤輸入作業(yè)到D盤的JOB文件*/int /*id,size, */status = 0,jobnum = 0;FILE *fp;char id10,size10;openFile(&fp,"d:job.cl","w");fprintf(fp,"job_IDtsizetstatus");printf("nnnnPlease input the jobs as fallow !nEnt

31、er a integer smaller than 1 to quit .njob_IDtsizen");do/*scanf("%d%d",&id,&size); */scanf("%st%s",id,size);if(atoi(id) > 0 && atoi(size) > 0)fprintf(fp,"n%st%st%d",id,size,status);/*fprintf(fp,"n%dt%dt%d",id,size,status); */jobnum+;e

32、lsebreak;while(1);if(jobnum)printf("nFinished to input the jobs !");elseprintf("nNo job was given .");errorMessage();fclose(fp);int makeJobList(struct jobList *jobs) /*從JOB文件中讀出作業(yè)并創(chuàng)建作業(yè)鏈表*/char jobID10,size10,status10;struct jobList *rear;FILE *fp;openFile(&fp,"d:job.cl&q

33、uot;,"r");fscanf(fp,"%s%s%s",jobID,size,status);if(*jobs = malloc(sizeof(struct jobList) = NULL)printf("nNot enough to allocate for the job .");fclose(fp);errorMessage();rear = *jobs;(*jobs)->next = NULL;while(!feof(fp)struct jobList *p;fscanf(fp,"%s%s%s",j

34、obID,size,status);if(p = malloc(sizeof(struct jobList) = NULL)printf("nNot enough to allocate for the job .");fclose(fp);errorMessage();p -> next = rear -> next;rear -> next = p;rear = rear -> next;rear -> id = atoi(jobID);rear -> size = atoi(size);rear -> status = ato

35、i(status);fclose(fp);return 0;int updateJobFile(struct jobList *jobs) /*更新作業(yè)鏈表中作業(yè)的狀態(tài)*/FILE *fp;struct jobList *p;openFile(&fp,"d:job.cl","w");fprintf(fp,"job_IDtsizetstatus");for(p = jobs -> next;p;p = p -> next)fprintf(fp,"n%dt%dt%d",p->id,p->

36、size,p->status);fclose(fp);return 0;int showFreeList(struct freeList *empty) /*空閑分區(qū)隊(duì)列顯示*/FILE *fp;struct freeList *p = empty -> next;int count = 0;openFile(&fp,"d:result.cl","a");fprintf(fp,"nnNow show the free list.");printf("nnNow show the free list.&qu

37、ot;);if(p)fprintf(fp,"nnumbertsizetstartAddress");printf("nnumbertsizetstartAddress");for(;p;p = p -> next)fprintf(fp,"n%dt%dt%d",+count,p -> size,p -> startAddress);printf("n%dt%dt%d",count,p -> size,p -> startAddress);fclose(fp);return 1;elsef

38、printf(fp,"nThe memory was used out !");printf("nThe memory was used out !"); fclose(fp);return 0;void getJobInfo(struct jobList *jobs,int id,int *size,int *status) /*獲取作業(yè)的信息*/struct jobList *p = jobs->next;while(p && p->id != id)p = p->next;if(p = NULL)printf(&q

39、uot;nCan't find the job which id is : %d .",id);errorMessage();else*size = p -> size;*status = p -> status;void updateJobStatus(struct jobList *jobs,int id,int status)struct jobList *p = (*jobs)->next;while(p && p->id != id)p = p->next;if(p = NULL)printf("nCan

40、9;t find the job which id is : %d .",id);errorMessage();elsep -> status = status;int showUsedList(struct jobList *jobs,struct usedList *used) /*作業(yè)占用鏈表顯示*/FILE *fp;struct usedList *p = used -> next;int count = 0,size,status;openFile(&fp,"d:result.cl","a");fprintf(fp

41、,"nnNow show the used list.");printf("nnNow show the used list.");if(p)fprintf(fp,"nnumbertjobIDtsizetstartAddress");printf("nnumbertjobIDtsizetstartAddress");for(;p;p = p -> next)getJobInfo(jobs,p -> jobID,&size,&status);fprintf(fp,"n%dt%dt

42、%dt%d",+count,p->jobID,size,p-> startAddress);printf("n%dt%dt%dt%d",count,p->jobID,size,p-> startAddress);fclose(fp);return 1;elsefprintf(fp,"nNo job in the memory ! You should input some jobs to it.");printf("nNo job in the memory ! You should input some jo

43、bs to it.");fclose(fp);return 0;int showJobList(struct jobList *jobs) /*顯示作業(yè)鏈表*/struct jobList *p;p = jobs->next;if(p = NULL)printf("nNo job in the list ! Try again next time.");return 0;printf("nnThe job list is as fallow :njob_IDtsizetstatus");while(p)printf("n%dt%

44、dt%d",p->id,p->size,p->status);p = p->next;return 1;void moveFragment(struct jobList *jobs,struct freeList *empty,struct usedList *used)int size,status;struct usedList *p;int address = memoryStartAddress; /*全局變量,初始化時(shí)分配存儲(chǔ)空間始址*/if(*empty)->next = NULL) /* 空閑分區(qū)鏈表為空,提示并返回 */printf(&q

45、uot;nThe memory was used out at all.nMay be you should finish some jobs first or press any key to try again !");getch();return;for(p = (*used) -> next;p;p = p-> next) /* 循環(huán)的修改占用分區(qū)的始址 */p -> startAddress = address;getJobInfo(jobs,p -> jobID,&size,&status); /* 由作業(yè)ID獲得作業(yè)大小 */ad

46、dress += size;(*empty)->next->startAddress = address;/*修改空閑分區(qū)的首節(jié)點(diǎn)始址、大小*/(*empty) -> next -> size = memorySize - (address - memoryStartAddress);(*empty) -> next -> next = NULL; /* 刪除首節(jié)點(diǎn)后的所有節(jié)點(diǎn) */void order(struct freeList *empty,int bySize,int inc)struct freeList *p,*q,*temp;int star

47、tAddress,size;for(p = (*empty) -> next;p;p = p -> next) /* 按bySize和inc兩個(gè)參數(shù)尋找合適的節(jié)點(diǎn),用temp指向它 */for(temp = q = p;q;q = q -> next)switch(bySize)case 0 : switch(inc)case 0:if(q->size < temp->size)temp = q;break;default:if(q->size > temp->size)temp = q;break; break;default: swit

48、ch(inc)case 0:if(q->startAddress < temp->startAddress)temp = q;break;default:if(q->startAddress > temp->startAddress)temp = q;break; break; /* 交換節(jié)點(diǎn)的成員值 */ if(temp != p) startAddress = p->startAddress;size = p->size;p->startAddress = temp->startAddress;p->size = temp-

49、>size;temp->startAddress = startAddress;temp->size = size;int allocate(struct freeList *empty,int size) /*為作業(yè)分配存儲(chǔ)空間、狀態(tài)必須為0*/struct freeList *p,*prep;int startAddress = -1;p = (*empty) -> next;while(p && p->size < size)p = p -> next;if(p != NULL)if(p -> size > size)

50、startAddress = p -> startAddress;p -> startAddress += size;p -> size -= size;else startAddress = p -> startAddress;prep = *empty;while(prep -> next != p)prep = prep -> next;prep -> next = p -> next;free(p);elseprintf("nMay be you should move the fragment together ."

51、); /* Unsuccessful ! */return startAddress;void insertUsedNode(struct usedList *used,int id,int startAddress) /*插入釋放的空間到used鏈表中(作業(yè)號(hào)為id,startAddress由函數(shù)13返回)*/struct usedList *q,*r,*prer;if(q = malloc(sizeof(struct usedList) = NULL)printf("nNot enough to allocate for the used node .");errorM

52、essage();q -> startAddress = startAddress;q -> jobID = id;prer = *used;r = (*used) -> next;while(r && r->startAddress < startAddress)prer = r;r = r -> next;q -> next = prer -> next;prer -> next = q;int finishJob(struct usedList *used,int id,int *startAddress) /*結(jié)束一個(gè)作業(yè)號(hào)為id的作業(yè),釋放存儲(chǔ)空間(由*startAddress返回空間的起始地址)*/struct usedList *p,*prep;prep = *used;p = prep -> next;while(p && p -> jobID != id)prep = p;p = p -> next;if(p = NULL)printf("nThe job which id is : %d is not in the memory !",id);return 0;else*sta

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論