操作系统源代码

操作系统源代码

ID:42534563

大小:125.52 KB

页数:19页

时间:2019-09-17

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

《操作系统源代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

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

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

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

4、f("Notenoughtoallocateforthefreenode.");errorMessage();}(*empty)->startAddress=startAddress;(*empty)->size=size;(*empty)->next=NULL;}voidiniMemory(void)/*初始化存储空间起始地址、大小*/{charMSA[10],MS[10];printf("Pleaseinputthestartaddressofthememory!");scanf("%s",MSA);memoryStartAddress=atoi(M

5、SA);printf("Pleaseinputthesizeofthememory!");scanf("%s",MS);memorySize=atoi(MS);}charselectFitMethod(void)/*选择适应算法*/{FILE*fp;charfitMethod;do{printf("Pleaseinputacharasfallowtoselectthefitmethod!1(Bestfit)2(Worstfit)3(Firstfit)4(Lastfit)");fitMethod=getche();}whil

6、e(fitMethod<'1'

7、

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

9、**********");break;case'3':fprintf(fp,"tFirstfit");fprintf(fp,"**********************************************");break;case'4':fprintf(fp,"tLastfit");fprintf(fp,"**********************************************");break;}fclose(fp);returnfitMethod;}voidinputJob(void

10、)/*从键盘输入作业到D

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

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

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