计算机操作系统实验计算机操作系统实验 计算机操作系统实验报告 实验一:了解操作系统 一、 实验目的: 通过在虚拟机中装载操作系统、并对硬盘进行分区的操作对操作系统有进一步和深入的了解,学会使用VMware Workstation,掌握操作系统的安装和对磁盘进行分区等各种操作 二、 实验原理: 在VMware Workstation中装载操作系统、对硬盘进行分区 三、 实验器材: 硬件:计算机 软件:VMware Workstation、windows系统镜像 四、 实验步骤: 1.打开计算机并运行VMware Wor...
value.a); }; printf("\t当前资源类型是 %c\t",'b'); scanf("%d",&alloc1->value.b); void main() printf("\t当前资源类型是 %c\t",'c'); { scanf("%d",&alloc1->value.c); int p,status=0,i,j,temp,flag=0; flag++; struct allocation allochead=alloc1; *allochead,*alloc1,*alloc2,*alloctemp; } struct max else *maxhead,*max1,*max2,*maxtemp; { struct available 6 / 13 计算机操作系统实验报告 alloc2=(struct scanf("%d",&max1->value.b); allocation*)malloc(sizeof(struct printf("\t当前资源类型是 %c\t",'c'); allocation)); scanf("%d",&max1->value.c); printf("\t当前资源类型是 %c\t",'a'); maxhead=max1; scanf("%d",&alloc2->value.a); flag++; printf("\t当前资源类型是 %c\t",'b'); } scanf("%d",&alloc2->value.b); else printf("\t当前资源类型是 %c\t",'c'); { scanf("%d",&alloc2->value.c); max2=(struct max*)malloc(sizeof(struct max)); alloc1->next=alloc2; printf("\t当前资源类型是 %c\t",'a'); alloc1=alloc2; scanf("%d",&max2->value.a); flag++; printf("\t当前资源类型是 %c\t",'b'); } scanf("%d",&max2->value.b); } printf("\t当前资源类型是 s %c\t",'c'); alloc2->next=NULL; scanf("%d",&max2->value.c); flag=0; max1->next=max2; max1=max2; for(i=0;i
next=NULL; if(flag==0) flag=0; { maxhead=max1=max2=(struct printf("\n请输入可以利用是资源数目\n"); max*)malloc(sizeof(struct max)); availablehead=workhead=(struct printf("\t当前资源类型是 %c\t",'a'); available*)malloc(sizeof(struct available)); scanf("%d",&max1->value.a); printf("\n"); printf("\t当前资源类型是 %c\t",'b'); printf("\t当前资源类型是 %c\t",'a'); 7 / 13 计算机操作系统实验报告 need2=(struct need*)malloc(sizeof(struct scanf("%d",&availablehead->value.a); need)); printf("\t当前资源类型是 %c\t",'b'); need2->value.a=(maxtemp->value.a)-(alloscanf("%d",&availablehead->value.b); ctemp->value.a); printf("\t当前资源类型是 %c\t",'c'); need2->value.b=(maxtemp->value.b)-(allo scanf("%d",&availablehead->value.c); ctemp->value.b); workhead=availablehead; need2->value.c=(maxtemp->value.c)-(allo ctemp->value.c); workhead->value=availablehead->value; flag=0; need1->next=need2; need1=need2; alloctemp=allochead; flag++; maxtemp=maxhead; } for(i=0;i
next; { alloctemp=alloctemp->next; if(flag==0) } { need2->next=NULL; needhead=need1=need2=(struct need*)malloc(sizeof(struct need)); flag=0; need1->next=need2->next=NULL; need1->value.a=(maxtemp->value.a)-(allofor(i=0;i
value.a); { need1->value.b=(maxtemp->value.b)-(alloif(flag==0) ctemp->value.b); { need1->value.c=(maxtemp->value.c)-(allo finishhead=finish1=finish2=(struct ctemp->value.c); finish*)malloc(sizeof(struct finish)); needhead=need1; finish1->next=finish2->next=NULL; flag++; finish1->value=0; } finishhead=finish1; else flag++; { } 8 / 13 计算机操作系统实验报告 else { { worktemp->value.a+=alloctemp->value.a; finish2=(struct finish*)malloc(sizeof(struct worktemp->value.b+=alloctemp->value.b; finish)); worktemp->value.c+=alloctemp->value.c; finish2->value=0; finishtemp->value=1; if(flag==0) finish1->next=finish2; { finish1=finish2; pathhead=path1=path2=(struct flag++; path*)malloc(sizeof(struct path)); } path1->next=path2->next=NULL; } path1->value=j+1; finish2->next=NULL; pathhead=path1; flag=0; flag++; } for(temp=0;temp
value=j+1; finishtemp=finishhead; path1->next=path2; worktemp=workhead; path1=path2; flag++; for(j=0;j
next; if(finishtemp->value==0) alloctemp=alloctemp->next; { needtemp=needtemp->next; if((needtemp->value.a<=worktemp->value .a)&&(needtemp->value.b<=worktemp->v} alue.b)&&(needtemp->value.c<=worktempelse ->value.c)) { 9 / 13 计算机操作系统实验报告 finishtemp=finishtemp->next; for(temp=0;temp
next; { needtemp=needtemp->next; if(finishtemp->value==0) } { printf("\n警告!当前系统是不安全的\n"); } else exit(0); { } finishtemp=finishtemp->next; finishtemp=finishtemp->next; alloctemp=alloctemp->next; } printf("\n当前系统是安全的!\n"); needtemp=needtemp->next; printf("\n安全序列为: \n"); } for(i=0;i
value);
path2->next=NULL; pathhead=pathhead->next; finishtemp=finishhead; }
pathtemp=pathhead; }
五、实验心得:
程序基本实现了银行家算法的功能,并在其基础上考虑了输出显示的格式的美观性、输入错误要求重新输入等几个方面,尽可能的使程序完整一些。
这段程序算是三个试验中最困难最复杂的一个,由于能力有限,所以在紧张的的编写和调试过程中遇到了许多的问
题
快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题
,通过查询资料、翻阅课本、向同学请教、多次调试等方法逐渐解决了大部分问题,编写的过程中也有比较一些算法的优劣性,找出比较好的算法,收获非常大。
通过本次实验,加深了我对银行家算法的理解。实验中遇到了许多问题,通过网络这个大平台问题最终也得到了解决。通过这次的编程,使得自己的动手能力又增强了许多,同时也加深了对理论知识的理解。
10 / 13
计算机操作系统实验报告
实验五:文件操作
一、实验目的:
1( 掌握文件系统的工作原理。
2( 理解文件系统的主要数据结构。
3( 编程实现文件操作。
二、实验内容:
1( 设计并实现一个一级(单用户)文件系统程序
提供以下操作:
文件创建/删除接口命令create/delete;
目录创建/删除接口命令midair/rmdir;
显示目录内容命令ls。
创建的文件不要求格式和内容
2( 在以上基础上世纪并实现一个二级文件系统
具备提供用户登录
文件、目录要有权限
三、程序源代码:
// FileControl.cpp: 主项目文件。 String ^dir="a";//设置目录名,注意/* 路径分量间用两个\\隔开。 程序功能:对文件进行操作:判断文件是否 String ^filename="b";//设置文件明 存在、创建新文件、读文件、写文件、创建 String ^path=dir+filename;
目录、删除目录、删除文件、将文件创建到 TextReader tReader(path);//读文件
类 指定目录中。
作者: TextWriter tWriter(path);//写文件日期:2011-12-4 类
*/ if(File::Exists(path))//判断文件#include "stdafx.h" 是否存在,若存在则可直接读写,否则创建
文件
using namespace System; {
using namespace System::IO; Console::WriteLine(L"文件存
在~");
int main(array