操作系统实验1Word格式文档下载.docx
- 文档编号:7433786
- 上传时间:2023-05-08
- 格式:DOCX
- 页数:28
- 大小:512.35KB
操作系统实验1Word格式文档下载.docx
《操作系统实验1Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《操作系统实验1Word格式文档下载.docx(28页珍藏版)》请在冰点文库上搜索。
网卡、串口、CAN总线
4.观察资源管理器,记录你使用使用的机器的资源情况:
CPU内存磁盘分区及容量文件目录树及文件属性。
5.观察设备管理器,记录你使用使用的机器的设备的配置情况(启动控制面板,到管理工具,再到计算机管理,进入设备管理器)
6.控制面板中看看系统还能让我们控制什么,特别了解“系统”、“显示”、“添加硬件”、“添加/删除程序”、“语音控制”等。
7.启动任务管理器,观察Windows对多任务管理列出的应用程序与启动的是否一致,系统中有多少进程?
为什麽会有那么多进程而都不是应用程序?
程序是由多个进运行的,且里面很多是系统进程
8.启动Windows的注册表,检查系统配置和设置,初步了解注册表的作用。
实验二、进程管理
模拟进程管理
通过这次试验,加深对进程概念的理解,进一步掌握进程状态的转变、进程调度的策略。
使用了PCB进行进程管理控制,建立三个基本的队列:
等待、执行、阻塞进行模拟。
操作系统的进程管理,模拟进程的调度,模拟用户的创建、执行、阻塞、挂起、唤醒等操作。
调时间因等待事件
度片到发生而唤醒
发生而睡眠
四、设计思路
1.建立一个结点,即PCB快包括用户标识域、指针域等。
2.建立三个队列(执行队列、就绪队列、等待队列)
3.根据进程状态转换实现对三个队列的具体操作
4.用switch选择语句选择状态
示例程序
#include"
stdio.h"
dos.h"
stdlib.h"
conio.h"
#include"
windows.h"
#defineSEC3
#defineNULL0
typedefstructPCB
{
intPID;
intUID;
structPCB*next;
}PCB;
PCB*really,*excute,*wait;
/*createqueueheader*/
/*queueoperation入列*/
intenqueue(PCB*head,PCB*node)
PCB*p;
p=head;
if(p->
next==NULL)
{
head->
next=node;
return1;
}
while(p)
{
p->
return1;
elsep=p->
next;
}/*enqueue*/
/*dequeue出队列*/
PCB*dequeue(PCB*head)
returnNULL;
else
p=p->
next=p->
p->
next=NULL;
returnp;
}
voidcreate()
p=(PCB*)malloc(sizeof(PCB));
printf("
inputPIDandUIDtoanewprocess\n"
);
scanf("
%d%d"
&
PID,&
UID);
if(enqueue(really,p))
printf("
createaprocess:
PID=%dUID=%d\n"
p->
PID,p->
createFailed\n"
intfexcute()
{
PCB*p=dequeue(really);
if(p==NULL)
NOprocessinqueue\n"
return0;
enqueue(excute,p);
addaprocessintoreallyqueueprocess:
PID=%dUID=%d\n"
intsuspend()
PCB*p=dequeue(excute);
return0;
enqueue(really,p);
PID=%dUID=%d\n"
intwake()
PCB*p=dequeue(wait);
addaprocessintowaitreallyprocess:
PID=%dUID=%d\n"
intblock()
enqueue(wait,p);
addaprocessintowaitqueueprocess:
intoutputqueue(PCB*head)
if(head->
queueisnull\n"
p=head->
PID=%dUID=%d\n"
voidoutput()
REALLYQUEUE:
\n"
outputqueue(really);
EXCUTEQUEUE:
outputqueue(excute);
WAITQUEUE:
outputqueue(wait);
intinit()
really=(PCB*)malloc(sizeof(PCB));
really->
excute=(PCB*)malloc(sizeof(PCB));
excute->
wait=(PCB*)malloc(sizeof(PCB));
wait->
_________PROCESSSECHUDLE_________\n"
nowiniting............\n"
inputPIDandUIDasinteger,00asover\n"
while
(1)
p->
scanf("
%d%d"
if(p->
PID==0&
&
UID==0)
break;
else
if(enqueue(really,p))
printf("
newprocessPID=%dUID=%dadded!
elsereturn0;
return1;
intrun()
PCB*p=excute;
ints=SEC;
if(excute->
noprocessinexcutequeue\n"
p=excute->
systemwillsleep%dasprocessrunning\n"
s);
Sleep(3);
process:
PID=%dUID=%dexcutesuccessed..\n"
excute->
free(p);
voidleave()
PCB*p,*t;
while(really->
next||excute->
next||wait->
next)
p=really->
while(p)
t=p->
p=t;
really->
p=wait->
wait->
exit(0);
voidhelp()
__________HELP_________\n"
\t-hHELPshowhelpoption\n"
\t-cCREATEcreateanewprocess,andputtoreallyqueue\n"
\t-bBLOCKblockanewprocessinexcutequeue\n"
\t-wWAKEwakeaprocessinwaitqueue\n"
\t-eEXCUTEexcuteaprocessinreallyqueue\n"
\t-sSUSPENDsuspendaprocessinexcutequeue\n"
\t-oOUTPUToutputallprocessinqueue\n"
\t-rRUNexcuteaprocessinexcutequeue\n"
\t-xEXITexitthispogram\n"
____________________________________\n"
\ttype'
H'
willshowthismenu\n"
voidmain()
charCOMMAND=NULL;
if(init()!
=1)
initfalied!
getch();
exit(0);
init...OK\n"
output();
help();
>
"
%c"
COMMAND);
switch(COMMAND)
case'
\n'
:
break;
h'
help();
C'
c'
create();
B'
b'
block();
W'
w'
wake();
S'
s'
suspend();
E'
e'
fexcute();
O'
o'
output();
X'
x'
leave();
R'
r'
run();
运行结果:
实验三、虚拟存储管理
一、实验题目
分页虚拟存储的页面淘汰算法
二、实验内容
通过编程实现FIFO淘汰算法功能,算出缺页率。
此题目学生自行独立编写
三、实验目的
深入理解FIFO算法
1.两个个队列(页面对列、内存队列)
2.手动输入测试序列
3.对是否命中进行判断
五、测试数据
页面序列:
432143543215
页面数:
3;
缺页率:
75%
4;
83.3%
程序如下
iostream"
iomanip"
usingnamespacestd;
#defineMax30
#defineSize10
voidInit(intBlock[],intm)
{inti;
for(i=0;
i<
m;
i++)
Block[i]=-1;
voidcreat(intPage[],intn)
n;
cin>
Page[i];
voidFIFO(intPage[],intBlock[],intn,intm)
inti,j,max_stay=0;
floatcount=0;
intget=-1,flag=-1,block_num=-1;
inttime[Size];
i++)
{time[i]=0;
{for(j=0;
j<
j++)
{if(Block[j]==-1)
{
get=j;
break;
}
}
for(j=0;
{if(Block[j]==Page[i])
flag=j;
{
if(time[j]>
max_stay)
max_stay=time[j];
block_num=j;
if(flag==-1)
{if(get!
=-1)
Block[get]=Page[i];
time[get]=0;
for(j=0;
=get;
{
time[j]++;
}
get=-1;
else
Block[block_num]=Page[i];
time[block_num]=0;
Size;
j++)
block_num=-1;
max_stay=0;
count++;
else
for(j=0;
time[j]++;
flag=-1;
j++)
cout<
<
setw(3)<
Block[j];
cout<
endl;
if(n>
m)
count=count+m;
cout<
缺页中断次数为:
count<
cout<
缺页率为:
count/m<
{intn,m,Page[Max],Block[Size];
*******先进先出FIFO页面置换算法*******"
--------------------------------------"
*******(默认:
-1表示物理块空闲)*******"
endl<
请输入系统为进程分配的物理块数(m<
=10):
;
while
(1)
{cin>
if(m>
Size||m<
1)
警告:
输入的数据错误!
请重新输入物理块数:
elsebreak;
Init(Block,m);
请输入总页面数(n<
=30):
cin>
\n请输入页面号引用串:
creat(Page,n);
FIFO算法过程如下:
FIFO(Page,Block,n,m);
getchar();
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 实验
![提示](https://static.bingdoc.com/images/bang_tan.gif)