操作系统实验指导书3
更新时间:2024-03-14 02:42:01 阅读量: 综合文库 文档下载
- 操作系统有哪些推荐度:
- 相关推荐
《计算机操作系统》
实 验 指 导 书
实验报告内容规范
实验报告内容要求如下:
课程名称、实验日期、实验名称、实验类型、班级、姓名(学号)、指导教师 一、实验目的及要求
本次实验所涉及并要求掌握的知识点。 二、实验环境
本次实验所使用的设备和软件。 三、实验内容
本次实验的具体内容。 四、实验步骤
按照实验过程列出实验步骤(涉及编程的,须首先进行算法设计,画出流程图)。
五、调试过程
详细记录实验过程中出现的问题及解决方法。 六、实验结果及分析 记录实验结果并进行分析。 七、总结
心得体会及改进意见。 八、附录(图)
目 录
实验一 进程调度设计 ............................................... 1 实验二 页面调度算法 ............................................... 4 实验三 文件管理 .................................................. 10 实验四
命令解释程序 .............................................. 13
实验一 进程调度设计
1. 目的和要求
进程调度是处理机管理的核心内容。本实验要求用C语言编写和调试一个简单的进程调度程序。通过本实验可以加深理解有关进程控制块、进程队列的概念,并体会和了解FIFO调度算法的具体实现方法。
2. 实验内容
①设计进程控制块PCB表结构。 ②编制FIFO进程调度算法.
3. 实验环境
PC兼容机/Windows、DOS系统/Turbo C 2.0
4. 参考程序
#include \#include \#define max 100
#define pfree 0 /*process end*/
#define running 1 /*process running status*/ #define aready 2 /*process aready status */
#define blocking 3 /*process aready blocking status*/ typedef struct node
{
char name; int status;
int precendence; int ax,bx,cx,dx; int pc; int psw;
struct node *next; /*pcb define*/ }pcb;
pcb *createprocess(pcb *head)
{
pcb *p,*q;
int a,b,c,d,m,n; char ID; int s; q=NULL;
printf(\scanf(\
scanf(\while(ID!='*') {
p=(pcb*)malloc(sizeof(pcb)); p->name=ID;
1
p->ax=a; p->bx=b; p->cx=c; p->dx=d; p->pc=m; p->psw=n;
p->precendence=pfree; p->status=aready; if(head==NULL) head=p; else
q->next=p; q=p;
printf(\scanf(\
scanf(\}
if(q!=NULL) q->next=NULL; q=head; while(q) {
printf(\
printf(\>bx,q->cx,q->dx,q->pc,q->psw); q=q->next; }
return head;/*createprocess end*/ }
void processfifo(pcb *head) /*use fifo */
{
pcb *p; p=head;
printf(\printf(\while(p!=NULL) {
p->status=running;
printf(\
printf(\p->pc,p->psw); /*check process running status */ p->status=0; p=p->next; }
printf(\p=head; while(p) {
printf(\p=p->next; }
printf(\
2
} main()
{
pcb *head; head=NULL;
head=createprocess(head); processfifo(head); }
3
实验二 页面调度算法
1. 目的和要求
通过本实验可以加深理解有关虚拟存储器的工作原理,进一步体会和了解页面替换算法的具体实现方法。
2. 实验内容
① 实现三种算法:先进先出;OPT;LRU
② 页面序列从指定的文本文件(TXT文件)中取出
③ 输出:第一行:每次淘汰的页面号,第二行:显示缺页的总次数
3. 实验环境
PC兼容机/Windows、DOS系统/Turbo C 2.0
4. 参考程序
#include
#define len sizeof(struct page)
struct page
{
int num; int tag;
struct page *next; };
struct page *create(int n) /*建立分配的内存空间,并初始化,返回头结点*/
{
int count=1;
struct page *p1,*p2,*head;
head=p2=p1=(struct page *)malloc(len); p1->tag=-1;p1->num=-1; while(count count++; p1=(struct page *)malloc(len); p1->tag=-1;p1->num=-1; p2->next=p1; p2=p1; } p2->next=null; return(head); } void FIFO(array,n) 4 int array[],n; { int *p; struct page *cp,*dp,*head,*new; int count=0; head=create(n); p=array; while(*p!=-1) { cp=dp=head; for(;cp->num!=*p&&cp->next!=null;) cp=cp->next; if (cp->num==*p) printf(\else { count++; cp=head; for(;cp->tag!=-1&&cp->next!=null;) cp=cp->next; if(cp->tag==-1) { cp->num=*p; cp->tag=0; printf(\} else { new=(struct page*)malloc(len); new->num=*p; new->tag=0; new->next=null; cp->next=new; head=head->next; printf(\free(dp); } } p++; } printf(\} void LRU(array,n) int array[],n; { int count=0,*p=array; struct page *head,*cp,*dp,*rp,*new,*endp; head=create(n); while(*p!=-1) { cp=dp=rp=endp=head; for(;endp->next!=null;) endp=endp->next; for(;cp->num!=*p&&cp->next!=null;) { 5 rp=cp;cp=cp->next;} if(cp->num==*p) { printf(\if(cp->next!=null) { if(cp!=head) rp->next=cp->next; else head=head->next; } endp->next=cp; cp->next=null; } else { count++; cp=rp=head; for(;cp->tag!=-1&&cp->next!=null;) cp=cp->next; if(cp->tag==-1) { printf(\cp->num=*p; cp->tag=0; } else { new=(struct page *)malloc(len); new->num=*p; new->tag=0; new->next=null; cp->next=new; dp=head; head=head->next; printf(\free(dp); } } p++; } printf(\} OPT(array,n) int array[],n; { int *p,*q,count=0,i; struct page *head,*cp,*dp,*new; p=array; head=create(n); while(*p!=-1) { cp=head; 6 for(;cp->num!=*p&&cp->next!=null;) cp=cp->next; if(cp->num!=*p) { count++; cp=head; for(;cp->tag!=-1&&cp->next!=null;) cp=cp->next; if(cp->tag==-1) { printf(\cp->num=*p; cp->tag=0; } else { i=1;q=p;q++;cp=head; while(*q!=-1&&i for(;*q!=cp->num&&cp->next!=null;) cp=cp->next; if(*q==cp->num) { cp->tag=1; i++; } q++;cp=head; } if(i==n) { for(;cp->tag!=0;) cp=cp->next; printf(\cp->num=*p; } else { cp=head; for(;cp->tag!=0;) cp=cp->next; if(cp==head) { for(;cp->next!=null;) cp=cp->next; new=(struct page *)malloc(len); new->num=*p; new->tag=0; new->next=null; cp->next=new; dp=head; head=head->next; printf(\free(dp); } else { printf(\cp->num=*p; 7 } } cp=head; for(;cp->next!=null;) {cp->tag=0;cp=cp->next;} cp->tag=0; } } else printf(\p++; } printf(\} main() { FILE *fp; char pt; char str[10]; int i,j=0; int page[50],space=0; for(i=0;i<50;i++) page[i]=-1; fp=fopen(\if(fp==NULL) { printf(\exit(0); } i=0; while((pt=fgetc(fp))!=EOF)/*将数字字符串转化成整型-开始*/ { if(pt>='0'&&pt<='9') { str[i]=pt;i++; space=0; } else { if(pt==' '||pt=='\\n') { if(space==1) break; else { str[i]='\\0'; page[j]=atoi(str); if(pt=='\\n') break; else { space=1; j++; i=0; } 8 } } } }/*结束*/ if(pt==EOF) {str[i]='\\0';page[j]=atoi(str);} i=0; while(page[i]!=-1) {printf(\fclose(fp); printf(\ printf(\printf(\FIFO(page,3); printf(\LRU(page,3); printf(\OPT(page,3); } 9 实验三 文件管理 1. 目的和要求 通过独立使用高级语言编写和调试一个简单的文件系统,达到模拟文件管理工作的目的,并进一步使学生对各种文件操作命令的实质内容和执行过程有比较深入的了解。 2. 实验内容 设计一个简单的文件系统,对文件的操作设计如下命令(使用菜单选择): creat 建立文件 delete 删除文件 list 文件列表 bye 退出 编写程序并调试通过,运行出结果,画出流程图 3. 实验环境 PC兼容机/Windows、DOS系统/Turbo C 2.0 4. 参考程序 #include struct filenode { char *filename; int lenth; struct filenode *next; } *filehead=NULL; list(struct filenode *fhead) { struct filenode *p; if(!fhead) {printf(\p=fhead; printf(\while(p) { printf(\ p=p->next; } } creat(char *fname) { int len; struct filenode *p,*q,*p1; p=p1=filehead; while(p) { if(!strcmp(fname,p->filename)) {printf(\ return; } p1=p; p=p->next; } q=malloc(sizeof(struct filenode)); printf(\scanf(\ strcpy(q->filename,fname); q->lenth=len; q->next=NULL; p1->next=q; if(!filehead) filehead=q; } delete(char *fname) { struct filenode *p,*q; p=q=filehead; while(p) { if(!strcmp(fname,p->filename)) { q->next=p->next; free(p); printf(\ return; } p=p->next; } printf(\} quit() { struct filenode *p,*q; p=filehead; while(p) { q=p; p=p->next; free(q); } } void main() { int choice; 11 char *newname=\/*struct filenode *filehead;*/ /*filehead=NULL; malloc(sizeof(struct filenode));*/ while(1) { printf(\ printf(\ printf(\ printf(\ printf(\ printf(\ printf(\ scanf(\ switch(choice) { case 1:printf(\ scanf(\ creat(newname); break; case 2:printf(\ scanf(\ delete(delname); break; case 3:list(filehead);break; case 4:quit();exit(0); } } } 12 实验四 命令解释程序 1. 目的和要求 理解命令解释程序工作原理。 2. 实验内容 利用高级语言编写一个微型命令解释程序,接收并解释执行以下命令: dir 列出当前目录 cop 文件1 文件2 拷贝文件 era 文件名 删除文件 dat 显示日期 tim 显示时间 end 结束,退出 画出程序流程图,编写程序,实现上述功能。 3. 实验环境 PC兼容机/Windows、DOS系统/Turbo C 2.0 4. 参考程序 #include int i,num; char *comm=\char gjz[6][4]={\ while(1) { printf(\printf(\printf(\printf(\printf(\printf(\printf(\printf(\printf(\scanf(\for(i=0;i<6;i++) { if(!strcmp(comm,gjz[i])) {num=i; break;} num=9; } command=\src=\des=\ delf=\switch(num) { case 0:command=\ case 1:printf(\ scanf(\ printf(\ scanf(\ command=strcat(command,\ command=strcat(command,src); command=strcat(command,\ command=strcat(command,des); break; case 2:printf(\ scanf(\ command=strcat(command,\ command=strcat(command,delf); break; case 3:command=\ case 4:command=\ case 5:printf(\ default:printf(\ } if(num>=0&&num<=5) system(command); } } 14
正在阅读:
操作系统实验指导书303-14
护士长手册12-03
市场营销策划实训日志05-13
2022年幼儿园保教工作计划07-31
看望病人的祝福语摘抄11-20
VRRP技术白皮书09-14
城市总体规划与土地利用总体规划区别11-30
驱动桥常见故障的排除05-13
- 计算机试题
- 【2012天津卷高考满分作文】鱼心人不知
- 教育心理学历年真题及答案--浙江教师资格考试
- 20180327-第六届“中金所杯”全国大学生金融知识大赛参考题库
- 洪林兴达煤矿2018年度水情水害预测预报
- 基本要道讲义
- 机电设备安装试运行异常现象分析与对策
- 《有机化学》复习资料-李月明
- 非常可乐非常MC2--非常可乐广告策划提案 - 图文
- 2011中考数学真题解析4 - 科学记数法(含答案)
- 企业人力资源管理师三级07- 09年真题及答案
- 基于单片机的光控自动窗帘控制系统设计说明书1 - 图文
- 20160802神华九江输煤皮带机安装方案001
- (共53套)新人教版一生物必修2(全册)教案汇总 word打印版
- 2014行政管理学总复习
- 中国银监会关于加强地方政府融资平台贷款风险监管的指导意见
- 民宿酒店核心竞争与研究
- 游园活动谜语大全2012
- 河南省天一大联考2016届高三英语5月阶段性测试试题(六)(A卷)
- 小型超市管理系统毕业论文详细设计4
- 指导书
- 操作系统
- 实验
- 让 观 察 成 为 一 种 习 惯
- 企业员工激励论文:浅析我国中小企业核心员工激励机制存在的问题
- 渝西矿业集团富家洞煤矿供水施救系统应急预案及管理制度
- 人教版五年级上册语文第三单元《口语交际·习作三》教学设计
- 满族服饰有哪几类
- 最新小学人教版五年级数学下《正方体的认识》教案教学设计
- 横沙东滩促淤圈围(六期)工程龙口保护混合软体排施工技术
- 精品人教版语文二年级上册选读5《鸡妈妈的新房子》word课堂实录
- 2007年秋至2010年秋江苏省计算机二级VB考试真题及参考答案
- 最新浙教版八年级上第1章三角形的初步认识单元测试题及答案
- 中国近现代史纲要习题册答案 第五章中国革命的新道路
- 人教版三年级上册语文配套套练习册答案
- 弘扬中华传统美德,争做文明的小学生 主题中队活动方案
- 武汉港阳逻港区煤码头一期工程文件材料立卷归档方案
- 2018-2019年苍南县金乡镇石砰学校一年级上册数学复习题无答案
- 基于智能视频分析摄像机的轨道异物检测
- 东北地区练习题
- 底座制造SOP - 图文
- 小学语文语文A版《二年级上》《第三单元》精品专题课后练习(
- 光谱透过率测试实验 - 图文