ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:48.18KB ,
资源ID:16291839      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16291839.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(操作系统实验报告Word格式文档下载.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

操作系统实验报告Word格式文档下载.docx

1、 Struct QueueNode *next;并设全程量:struct QueueNode *ready_head=NULL,/ready队列队首指针*ready_tail=NULL , /ready队列队尾指针*blocked_head=NULL,/blocked队列队首指针*blocked_tail=NULL; /blocked队列队尾指针(3)设计子程序: start_state(); 读入假设的数据,设置系统初始状态,即初始化就绪队列和阻塞队列。dispath();模拟调度,当就绪队列的队首进程运行一个时间片后,放到就绪队列末尾,每次都是队首进程进行调度,一个进程运行结束就从就绪队列

2、中删除,当到t个时间片后,唤醒阻塞队列队首进程。 calculate(); 就绪进程运行一次,usecpu加1,当就绪队列为空时unusecpu加1,CPU利用率为use_cpu/(use_cpu+unuse_cpu)。5源代码:#includestdlib.hstruct PCB_type int state ; /进程状态 /2-表示执行状态 /1-表示就绪状态 /0-表示阻塞 /运行需要的CPU时间(需运行的时间片个数);struct QueueNode struct QueueNode *next;struct QueueNode *ready_head=NULL, /ready队列队

3、首指针 *ready_tail=NULL, /ready队列队尾指针 *block_head=NULL, /blocked队列队首指针 *block_tail=NULL;int use_cpu,unuse_cpu;void start_state() /读入假设的数据,设置系统初始状态 int n,m; int i; struct QueueNode *p,*q; printf(输入就绪节点个数n:); scanf(%d,&n);输入阻塞节点个数m:m); p=(struct QueueNode *)malloc(sizeof(struct QueueNode); p-next =NULL;

4、ready_head=ready_tail=p; for(i=0;iPCB.pid,&PCB.cpu_time); ready_tail-next=p; ready_tail=p; q=(struct QueueNode *)malloc(sizeof(struct QueueNode); q- block_head=block_tail=q;m;next=NULL;PCB.state=0;输入阻塞进程%d的pid和cpu_time:q- block_tail-next=q; block_tail=q;n处于就绪状态的进程有:n p=ready_head-next; i=1; while(p)

5、 printf(“进程%d的pid和state和cpu_time:%5d%5d%5dn,i,p-PCB.pid,p-PCB.state,p- p=p- i+;void dispath() /模拟调度 int x=0,t; use_cpu=0; unuse_cpu=0;输入t:t);开始调度n while(ready_head!=ready_tail|block_head!=block_tail) if(ready_head!=ready_tail) ready_head-next=p- p- if(ready_head-next=NULL) ready_tail=ready_head; PCB

6、.state=2; printf(进程%d调度t,p-PCB.pid); use_cpu+; x+;PCB.cpu_time-; if(p-PCB.cpu_time) ready_tail=p; else printf(进程%d完成t free(p); else unuse_cpu+;空闲一个时间片t if(x=t&block_head! q=block_head- block_head-next=q- q- if(block_head- block_tail=block_head; ready_tail- ready_tail=q; x=0;void calculate() /计算CPU利用

7、率ncpu的利用率%.2fn,(float)use_cpu/(use_cpu+unuse_cpu);void main()start_state(); dispath();6运行结果:7实验总结:实验帮我复习了数据结构和C语言,且巩固课本知识,知道了如何定义结构体,如何在队列中增删节点。模拟进程调度帮我们巩固了进程三状态之间的变迁。懂得调式的重要性。总之,我们明白了理论联系实际。多看书,多上机。实验三 可变分区存储管理通过这次实验,加深对存管理的认识,进一步掌握存的分配、回收算法的思想。阅读教材计算机操作系统第四章,掌握存储器管理相关概念和原理。编写程序模拟实现存的动态分区法存储管理。存空闲区

8、使用自由链管理,采用最坏适应算法从自由链中寻找空闲区进行分配,存回收时假定不做与相邻空闲区的合并。假定系统的存共640K,初始状态为操作系统本身占用64K。在t1时间之后,有作业A、B、C、D分别请求8K、16K、64K、124K的存空间;在t2时间之后,作业C完成;在t3时间之后,作业E请求50K的存空间;在t4时间之后,作业D完成。要求编程序分别输出t1、t2、t3、t4时刻存的空闲区的状态。4.设计思想模拟存分配和回收,要设置两个链队列,一个空闲区链和一个占用区链,空闲区链节点有起始地址,大小和指向下一节点的指针等数据域,占用区链节点有起始地址,大小,作业名和指向下一节点的指针等数据域,

9、本实验用最坏适应算法,每次作业申请存都是从空闲链队头节点分配,如果相等,就删除空闲头结点,如果小于申请的,就不分配,否则就划分存给作业,剩下的存大小,重新插入空闲链队,按从大到小,接着把作业占用的存放到占用区链节点的末尾。每次作业运行完,就要回收其占用的存大小,把作业节点按从大到小插入到空闲链队中。5.源代码:struct freelinkNodeint len;int address;struct freelinkNode *next;struct busylinkNodechar name;struct busylinkNode *next;struct freelinkNode *fre

10、e_head=NULL; /自由链队列(带头结点)队首指针 struct busylinkNode *busy_head=NULL; /占用区队列队(带头结点)首指针 struct busylinkNode *busy_tail=NULL; /占用区队列队尾指针void start(void) /* 设置系统初始状态*/ struct freelinkNode *p; struct busylinkNode *q; free_head=(struct freelinkNode*)malloc(sizeof(struct freelinkNode); free_head- / 创建自由链头结点

11、busy_head=busy_tail=(struct busylinkNode*)malloc(sizeof(struct busylinkNode); busy_head- / 创建占用链头结点 p=(struct freelinkNode *)malloc(sizeof(struct freelinkNode);address=64;len=640-64;/OS占用了64K q=(struct busylinkNode *)malloc(sizeof(struct busylinkNode);name=S; /* S表示操作系统占用 */len=64;address=0; busy_ta

12、il=q;void requireMemo(char name, int require) /*模拟存分配*/ freelinkNode *w,*u,*v; busylinkNode *p; if(free_head-next-len=require) p=(struct busylinkNode*)malloc(sizeof(struct busylinkNode);name=name;address=free_head-address;len=require; busy_tail- busy_tail=p; else Cant allocate w=free_head-next=w- if

13、(w-len=require) free(w); w-address=w-address+require; w-len=w-len-require; u=free_head; v=free_head- while(v!=NULL)&(v-w-len) u=v; v=v- u-next=w;next=v;void freeMemo(char name) /* 模拟存回收*/ int len; int address; busylinkNode *q,*p; q=busy_head; p=busy_head- while(p!(p-name!=name) q=p; p=p- if (p=NULL)

14、%c is not exist,name); if(p=busy_tail) busy_tail=q; q- len=p-len; address=p- free(p); w=(struct freelinkNode*)malloc(sizeof(struct freelinkNode);len=len;address=address; u=v;v=v-void past(int time) /* 模拟系统过了time 时间*/过了时间%d后:,time);void printlink() /* 输出存空闲情况(自由链的结点) */ freelinkNode *p;存的空闲情况为: p=fre

15、e_head- while(p!=NULL) printf(存的起始地址和存的大小%5dt%5d:address,p-len); int t1=1,t2=2,t3=3,t4=4; start(); past(t1); requireMemo(A,8);B,16);C,64);D,124); printlink(); past(t2); freeMemo( past(t3);E,50); past(t4); );6.运行结果:7.实验总结:巩固编程能力,和调式能力,复习课本知识,明白理论联系实际的重要性,动手能力非常重要,多看书,多独立思考,品味痛苦的过程,享受成功的喜悦。院系:数计学院 班级:大类6班学号:*姓名:明章辉 指导教师:徐军利

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1