东北大学操作系统实验报告+源代码+流程图源文件+课件


代码基于LINUX环境,一共包含5次实验报告 实验1:熟悉Linux系统 实验2:进程状态 实验3:进程同步和通信 实验4:进程的管道通信 实验5:页面置换算法 源码包括:FIFO_LRU、IPC、os、producer
资源截图
代码片段和文件信息
#include  
#include  
#include  
#include  
#include 
#include 
#include 
#include 
#include 
#define frame_num 4
#define total_instruction 12

struct one_frame
{
int page_no;
char flag;
};

struct one_frame M_frame[frame_num];
int Acess_Series[total_instruction];
float hitTime hitRate = 0;

void FIFO() {
hitTime = 0;
hitRate = 0;
//数据结构M_frame的初始化
for (int i = 0; i < frame_num; i++) {
M_frame[i].page_no = 0;
}

int pos = 0; //0 <= pos < frame_num - 1 记录最先进入的位置

printf(“执行FIFO页面置换算法:
“);
for (int i = 0; i < total_instruction; i++)
{
printf(“调入页面是%d  “ Acess_Series[i]);
for (int j = 0; j < frame_num; j++)
{
if (Acess_Series[i] == M_frame[j].page_no) {
hitTime++; 
printf(“命中    “); 
break; 
}
if (M_frame[j].page_no == 0)
{
M_frame[j].page_no = Acess_Series[i];
printf(“未命中  “);
break;
}
if (j == frame_num - 1)
{
M_frame[pos].page_no = Acess_Series[i];
pos++;
if (pos == frame_num) {
pos = 0;
}
printf(“未命中  “);

}
printf(“内存情况为:%d |%d |%d |%d
“ M_frame[0].page_no M_frame[1].page_no M_frame[2].page_no M_frame[3].page_no);
}
hitRate = hitTime / total_instruction;
printf(“命中次数:%f
“ hitTime);
printf(“命中率:%f
“ hitRate);
}

void BE() {
hitTime = 0;
hitRate = 0;
struct one_frame BE_frame[frame_num+1];
//数据结构M_frame的初始化
for (int i = 0; i < frame_num+1; i++) {
M_frame[i].page_no = 0;
}

int pos = 0; //0 <= pos < frame_num - 1 记录最先进入的位置

printf(“执行BE置换测试:
“);
for (int i = 0; i < total_instruction; i++)
{
printf(“调入页面是%d  “ Acess_Series[i]);
for (int j = 0; j < frame_num+1; j++)
{
if (Acess_Series[i] == M_frame[j].page_no) {
hitTime++; 
printf(“命中    “); 
break; 
}
if (M_frame[j].page_no == 0)
{
M_frame[j].page_no = Acess_Series[i];
printf(“未命中  “);
break;
}
if (j == frame_num)
{
M_frame[pos].page_no = Acess_Series[i];
pos++;
if (pos == frame_num+1) {
pos = 0;
}
printf(“未命中  “);

}
printf(“内存情况为:%d |%d |%d |%d |%d 
“ M_frame[0].page_no M_frame[1].page_no M_frame[2].page_no M_frame[3].page_noM_frame[4].page_no);
}
hitRate = hitTime / total_instruction;
printf(“命中次数:%f
“ hitTime);
printf(“命中率:%f
“ hitRate);
}


void LRU() {
hitTime = 0;
hitRate = 0;
//数据结构M_frame的初始化
for (int i = 0; i < frame_num; i++) {
M_frame[i].page_no = 0;
}
printf(“执行LRU页面置换算法:
“);
for (int i = 0; i < total_instruction; i++)
{
printf(“调入页面是%d  “ Acess_Series[i]);
for (int j = 0; j < frame_num; j++)
{
if (M_frame[j].page_no == Acess_Series[i])//命中
{
M_frame[j].flag = frame_num;
hitTime++;
printf(“命中    “);
for (int n = 0; n < frame_num; n++) {

M_frame[n].flag -= 1;

}
break;
}
if

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-05-29 23:38  实验
     文件      251661  2018-05-07 22:52  实验2.pptx
     文件      275420  2018-05-07 22:52  实验3.pptx
     文件      281517  2018-05-15 12:48  实验5.pptx
     文件        4783  2018-05-14 20:08  实验FIFO_LRU.cpp
     文件        1676  2018-05-07 23:23  实验IPC.cpp
     文件        4764  2018-04-08 16:42  实验os.cpp
     目录           0  2018-05-14 23:06  实验os_lab
     文件          93  2018-03-29 21:27  实验os_lab.~lock.1.doc#
     文件          93  2018-03-29 21:27  实验os_lab.~lock.head.odt#
     文件          93  2018-03-29 21:27  实验os_lab.~lock.linux.sxw#
     文件          74  2018-03-29 21:27  实验os_lab1.c
     文件          74  2018-03-29 21:27  实验os_lab1.cpp
     文件        7340  2018-03-29 21:27  实验os_lab1.out
     文件       12288  2018-03-29 21:27  实验os_lab11.doc
     文件           0  2018-03-29 21:27  实验os_lab2.c
     文件      676352  2018-03-29 21:27  实验os_lab2.odp
     文件       11824  2018-03-29 21:27  实验os_lab2.out
     文件      698368  2018-03-29 21:27  实验os_lab3.odp
     文件      747520  2018-03-29 21:27  实验os_lab4.odp
     文件        7340  2018-03-29 21:27  实验os_lab4.out
     文件      586972  2018-03-29 21:27  实验os_lab4_new.odp
     文件      691200  2018-03-29 21:27  实验os_lab5.odp
     文件       11824  2018-03-29 21:27  实验os_lab5.out
     文件           0  2018-03-29 21:27  实验os_lab8.c
     文件        6667  2018-03-29 21:27  实验os_labhead.odt
     文件        8881  2018-03-29 21:27  实验os_lablinux.sxw
     文件        9193  2018-03-29 21:27  实验os_lablinux0.odt
     文件        4737  2018-03-29 21:27  实验os_labpcb.c
     文件       16169  2018-03-29 21:27  实验os_lab实验说明.odp
     文件        3067  2018-04-17 20:30  实验producer.cpp
............此处省略19个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)