操作系统源代码.doc

操作系统源代码.doc

ID:51401578

大小:125.50 KB

页数:19页

时间:2020-03-23

操作系统源代码.doc_第1页
操作系统源代码.doc_第2页
操作系统源代码.doc_第3页
操作系统源代码.doc_第4页
操作系统源代码.doc_第5页
资源描述:

《操作系统源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、#include#include#includeintmemoryStartAddress=-1;intmemorySize=-1;structjobList{intid;/*作业ID*/intsize;/*作业大小(需要的存储空间大小)*/intstatus;/*作业状态0:newjob,1:inthememory,2:finished.*/structjobList*next;/*作业链表指针*/};structfreeList{intstartAddress;/*分区起始

2、地址*/intsize;/*分区大小*/structfreeList*next;/*分区链表指针*/};structusedList{intstartAddress;/*分区起始地址*/intjobID;/*分区中存放作业ID*/structusedList*next;/*分区链表指针*/};voiderrorMessage(void)/*出现严重错误时显示信息并结束程序*/{printf("tError!a");printf("Pressanykeytoexit!");getch();exit(1);}voidope

3、nFile(FILE**fp,char*filename,char*mode)/*以要求的方式打开文件*/{if((*fp=fopen(filename,mode))==NULL){printf("Can'topen%sinmode%s.",filename,mode);errorMessage();}}voidmakeFreeNode(structfreeList**empty,intstartAddress,intsize)/*根据参数startAddress、size创建空闲节点,由empty指针返回*/{if((*em

4、pty=malloc(sizeof(structfreeList)))==NULL){printf("Notenoughtoallocateforthefreenode.");errorMessage();}(*empty)->startAddress=startAddress;(*empty)->size=size;(*empty)->next=NULL;}voidiniMemory(void)/*初始化存储空间起始地址、大小*/{charMSA[10],MS[10];printf("Pleaseinputthestar

5、taddressofthememory!");scanf("%s",MSA);memoryStartAddress=atoi(MSA);printf("Pleaseinputthesizeofthememory!");scanf("%s",MS);memorySize=atoi(MS);}charselectFitMethod(void)/*选择适应算法*/{FILE*fp;charfitMethod;do{printf("Pleaseinputacharasfallowtoselectthefitmethod!

6、1(Bestfit)2(Worstfit)3(Firstfit)4(Lastfit)");fitMethod=getche();}while(fitMethod<'1'

7、

8、fitMethod>'4');openFile(&fp,"d:\result.cl","a");switch(fitMethod){case'1':fprintf(fp,"tBestfit");fprintf(fp,"**********************************************");b

9、reak;case'2':fprintf(fp,"tWorstfit");fprintf(fp,"**********************************************");break;case'3':fprintf(fp,"tFirstfit");fprintf(fp,"**********************************************");break;case'4':fprintf(fp,"tLastfit");fpr

10、intf(fp,"**********************************************");break;}fclose(fp);returnfitMethod;}voidinputJob(void)/*从键盘输入作业到D

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。