完整word版东北大学操作系统第一次实验报告Word格式.docx

上传人:b****2 文档编号:5007596 上传时间:2023-05-04 格式:DOCX 页数:16 大小:163.67KB
下载 相关 举报
完整word版东北大学操作系统第一次实验报告Word格式.docx_第1页
第1页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第2页
第2页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第3页
第3页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第4页
第4页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第5页
第5页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第6页
第6页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第7页
第7页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第8页
第8页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第9页
第9页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第10页
第10页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第11页
第11页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第12页
第12页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第13页
第13页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第14页
第14页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第15页
第15页 / 共16页
完整word版东北大学操作系统第一次实验报告Word格式.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

完整word版东北大学操作系统第一次实验报告Word格式.docx

《完整word版东北大学操作系统第一次实验报告Word格式.docx》由会员分享,可在线阅读,更多相关《完整word版东北大学操作系统第一次实验报告Word格式.docx(16页珍藏版)》请在冰点文库上搜索。

完整word版东北大学操作系统第一次实验报告Word格式.docx

1、设计并实现一个模拟进程状态转换及其相应PCB组织结构变化的程序;

2、独立设计、编写、调试程序;

3、程序界面应能反映出在模拟条件下,进程之间状态转换及其对应的PCB组织的变化。

4、进程的状态模型(三状态、五状态、七状态或其它)可自行选择,

5、代码书写要规范,要适当地加入注释;

6、鼓励在实验中加入新的观点或想法,并加以实现;

7、认真进行预习,完成预习报告;

8、实验完成后,要认真总结,完成实验报告。

四、程序流程图

图4.1进程转换流程

五、使用的数据结构及其说明

structPCB//进程控制块PCB

{

charname;

//名字标识

stringstate;

//状态

inttime;

//执行时间

};

typedefstructPCBElemType;

structQNode

ElemTypedata;

structQNode*next;

//链式队列结点

typedefstructQNodeQNode;

//结点

typedefstructQNode*PNode;

typedefstruct

PNodefrnt;

PNoderear;

}LinkQueue;

//链式队列

六、程序源代码、文档注释及文字说明

#include<

iostream>

#include<

stdlib.h>

fstream>

windows.h>

usingnamespacestd;

voidInsert_Queue(LinkQueue&

Q,ElemTypee)//插入

PNodeptr=(PNode)malloc(sizeof(QNode));

if(!

ptr)

{

cout<

<

"

(Insert_Queue)动态分配结点失败!

\n"

;

exit

(1);

}

ptr->

data=e;

next=NULL;

Q.rear->

next=ptr;

Q.rear=ptr;

}

intInit_Queue(LinkQueue&

Q)//初始化

Q.frnt=Q.rear=(PNode)malloc(sizeof(QNode));

Q.frnt)

Q.frnt->

return0;

intDelete_Queue(LinkQueue&

Q,ElemType&

e)//删除(头结点删除法)

PNodeptr;

if(Q.frnt==Q.rear)//空队列

return1;

ptr=Q.frnt->

next;

//删除第一个元素

next=ptr->

e=ptr->

data;

if(Q.rear==ptr)

Q.rear=Q.frnt;

free(ptr);

intEmpty_Queue(LinkQueueQ)//判断是否为空队列,是1,否0

return(Q.frnt==Q.rear?

1:

0);

voidPrint_Queue(LinkQueue&

Q)//打印队列元素

if(Q.frnt==Q.rear)//队列为空时,返回提示信息

\t\tempty.\n"

else

while(ptr!

=NULL)

\t\tProcess'

sname:

"

ptr->

data.name<

endl;

ptr=ptr->

voidPrint_State(LinkQueue&

Q_Ready,LinkQueue&

Q_Running,LinkQueue&

Q_Blocked)

\t-----------------------------\n"

\n\tStatus_Ready:

Print_Queue(Q_Ready);

\n\tStatus_Running:

\n"

Print_Queue(Q_Running);

\n\tStatus_Blocked:

Print_Queue(Q_Blocked);

\n\t-----------------------------\n"

voidTransision_Two(LinkQueue&

Q1,LinkQueue&

Q2)

ElemTypee;

if(Empty_Queue(Q1))

\nERROR!

前一个队列为空!

.\n"

return;

Delete_Queue(Q1,e);

Insert_Queue(Q2,e);

intmain()

intnum;

charchoose;

LinkQueueQ_Ready,Q_Running,Q_Blocked;

Init_Queue(Q_Ready);

Init_Queue(Q_Blocked);

Init_Queue(Q_Running);

\t请输入进入Ready态的进程数目:

cin>

>

num;

for(inti=1;

i<

=num;

i++)

\t第"

i<

个进程----"

\n\t请输入进程名字:

e.name;

\t请输入进程状态:

e.state;

\t请输入进程时间:

e.time;

Insert_Queue(Q_Ready,e);

\t***********************************进程状态转换分割线************************************\n"

\tN=创建进程(New),D=调度(Dispatch),T=时间片到(Timeout),W=等待事件(EventWait),"

\n\tC=事件发生(EventOccur),E=退出进程(Exit),P=输出各进程(Print),O=退出程序(Overgame)"

\t请选择操作(N,D,T,W,C,E,P,O):

choose;

while(choose!

='

O'

switch(choose)

case'

N'

:

//N=创建进程(New)

Print_State(Q_Ready,Q_Running,Q_Blocked);

break;

D'

//D=调度(Dispatch)

Transision_Two(Q_Ready,Q_Running);

T'

//T=时间片到(Timeout)

Transision_Two(Q_Running,Q_Ready);

W'

//W=等待事件(EventWait)

Transision_Two(Q_Running,Q_Blocked);

C'

//C=事件发生(EventOccur)

Transision_Two(Q_Blocked,Q_Ready);

E'

//E=退出进程(Exit)

if(Empty_Queue(Q_Running))

\n\tReleaseError!

没有正在执行的进程.\n"

Delete_Queue(Q_Running,e);

P'

//P=输出各进程(Print)

//O=退出程序(Overgame)

default:

输出不符合规则,请重新输入!

//操作异常处理

七、运行结果及其说明

运行结果如下截图所示,在截图中相继调用了"

N=创建进程(New),D=调度(Dispatch),T=时间片到(Timeout),W=等待事件(EventWait),C=事件发生(EventOccur),E=退出进程(Exit),P=输出各进程(Print),O=退出程序(Overgame)"

命令。

八、程序使用说明

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > PPT模板 > 国外设计风格

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2