资源描述:
《广工操作系统试验报告广东工业大学13级2016年用》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验报告课程名称___操作系统实验______学生学院___计算机学院_________专业班级计算机科学与技术一班学号___xxxxxxxxxx_____学生姓名____xxxx________指导教师孙为军___________2015年12月30日ofwork,relationships,needandpossibility,putqualityfirst."Improvestructure",referspartycarefully".IsamustadheretotheindividualabsorptionTheprincipleofthedevel
2、opmentofamatureone,andstrictlyperformintheadmissionprocedure,topreventthePartymember实验一进程调度一、实验目的编写并调试一个模拟的进程调度程序,以加深对进程的概念及进程调度算法的理解.二、实验内容1.采用“短进程优先”调度算法对五个进程进行调度。每个进程有一个进程控制块(PCB)表示。进程控制块可以包含如下信息:进程名、到达时间、需要运行时间、已用CPU时间、进程状态等等。2.每个进程的状态可以是就绪W(Wait)、运行R(Run)、或完成F(Finish)三种状态之一。每进行一
3、次调度程序都打印一次运行进程、就绪队列、以及各个进程的PCB,以便进行检查。重复以上过程,直到所要进程都完成为止。在文档最后我添加了一些个人的总结和心得,应该会对大家有些帮助请注意看,另外本实验的代码已经被我上传至CSDN网站上,需要参考的同学请去搜索。三、实现思路在多道程序系统中,一个作业被提交后必须经过处理机调度后,方能获得处理机执行。对调度的处理又都可采用不同的调度方式和调度算法。调度算法是指:根据系统的资源分配策略所规定的资源分配算法。短进程优先调度算法是指对短进程优先调度的算法,它是从后备队列中选择一个或者若干个进程,将处理机分配给它,使它立即执行并一
4、直执行到完成,或发生某事件而被阻塞放弃处理机时再重新调度。四、主要的数据结构#include"stdio.h"#include#include#definegetpch(type)(type*)malloc(sizeof(type))ofwork,relationships,needandpossibility,putqualityfirst."Improvestructure",referspartycarefully".IsamustadheretotheindividualabsorptionTheprincipleo
5、fthedevelopmentofamatureone,andstrictlyperformintheadmissionprocedure,topreventthePartymember#defineNULL0structpcb{/*定义进程控制块PCB*/charname[10];//进程名charstate;//状态intsuper;//优先数intntime;//需要运行时间intrtime;//运行时间structpcb*link;}*ready=NULL,*p;typedefstructpcbPCB;intnum;sort()/*建立对进程进行短进程优
6、先排列函数*/{PCB*first,*second;intinsert=0;if((ready==NULL)
7、
8、((p->ntime)<(ready->ntime)))/*需要运行时间最小者,插入队首*/{p->link=ready;ready=p;}else/*进程比较需要运行时间,插入适当的位置中*/{first=ready;second=first->link;while(second!=NULL){if((p->ntime)<(second->ntime))/*若插入进程比当前进程需要运行时间小,*/{/*插入到当前进程前面*/p->link=secon
9、d;first->link=p;second=NULL;insert=1;}else/*插入进程需要运行时间最大,则插入到队尾*/{first=first->link;second=second->link;}}if(insert==0)first->link=p;}}ofwork,relationships,needandpossibility,putqualityfirst."Improvestructure",referspartycarefully".IsamustadheretotheindividualabsorptionTheprincipleof
10、thedevelopme