东北大学操作系统实验之Linux及进程状态.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《东北大学操作系统实验之Linux及进程状态.doc》由会员分享,可在线阅读,更多相关《东北大学操作系统实验之Linux及进程状态.doc(11页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、操作系统实验报告一 实验一 进程状态转换及其PCB的变化一、实验目的:自行编制模拟程序,通过形象化的状态显示,使学生理解进程的概念、进程之间的状态转换及其所带来的PCB内容 、组织的变化,理解进程与其PCB间的一一对应关系。二、实验内容及要求:(1)、 设计并实现一个模拟进程状态转换及其相应PCB内容、组织结构变化的程序。(2)、 独立编写、调试程序。进程的数目、进程的状态模型(三状态、五状态、七状态或其它)以及PCB的组织形式可自行选择。(3)、 合理设计与进程PCB相对应的数据结构。PCB的内容要涵盖进程的基本信息、控制信息、资源需求及现场信息。(4)、 设计出可视性较好的界面,应能反映出
2、进程状态的变化引起的对应PCB内容、组织结构的变化。(5)、 代码书写要规范,要适当地加入注释。(6)、 鼓励在实验中加入新的观点或想法,并加以实现。(7)、 认真进行预习,完成预习报告。 (8)、 实验完成后,要认真总结,完成实验报告。五状态模型: 三、 主要数据结构:struct Run_type /运行态进程char name;int state;int needtime;int priority;struct Ready_type /就绪态进程char name;int needtime;int priority;struct Blocked_type /阻塞态进程char name;
3、int needtime;int priority;四、 程序源代码:#include#include#includeint i=0; int j=0;struct Run_typechar name;int state;int needtime;int priority;struct Ready_typechar name;int needtime;int priority;struct Blocked_typechar name;int needtime;int priority;struct Run_type Cpu;struct Ready_type Ready10;struct Bl
4、ocked_type Blocked10;void Creat()/创建一个新的进程int k=0;label1:printf( input new process name(input a letter): n);scanf(%s,&(Readyi.name);getchar();for(k=0;ki;k+)if(Readyi.name=Readyk.name|Readyi.name=Readyk.name+32|Readyi.name=Readyk.name-32)printf(the process is already exist!);goto label1;printf(input
5、needtime (input a int number):n);label3:scanf(%d,&(Readyi.needtime);getchar();if(Readyi.needtime100)printf(please input the true needtime(1-100)n);goto label3;printf( input the priority(1-10): n);label2:scanf(%d,&(Readyi.priority);getchar();if(Readyi.priority10)printf(please 1-10!n);goto label2;i+;v
6、oid Dispath()/P135 int t;char v;int k;int j;if(Cpu.state=0)if(Readyi-1.needtime=0)printf(* there is no process ready!n);exit(0);elsefor(k=0;ki-1;k+)for(j=0;jReadyj+1.priority)t=Readyj.priority;Readyj.priority=Readyj+1.priority;Readyj+1.priority=t;t=Readyj.needtime;Readyj.needtime=Readyj+1.needtime;R
7、eadyj+1.needtime=t;v=Readyj.name;Readyj.name=Readyj+1.name;Readyj+1.name=v;-i;Cpu.name=Readyi.name;Cpu.needtime=Readyi.needtime;Cpu.priority=Readyi.priority;Cpu.state=1;printf(*%5c is send to cpu! n,Cpu.name);Cpu.needtime-;if(Cpu.needtime=0)printf(*%5c is finished n,Cpu.name);Cpu.state=0;else Readyi
8、.name=Cpu.name;Readyi.needtime=Cpu.needtime;Readyi.priority=Cpu.priority;for(k=0;ki;k+)for(j=0;jReadyj+1.priority)t=Readyj.priority;Readyj.priority=Readyj+1.priority;Readyj+1.priority=t;t=Readyj.needtime;Readyj.needtime=Readyj+1.needtime;Readyj+1.needtime=t;v=Readyj.name;Readyj.name=Readyj+1.name;Re
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 东北大学 操作系统 实验 Linux 进程 状态
![提示](https://www.deliwenku.com/images/bang_tan.gif)
限制150内