91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 940KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-09
  • 語言: 其他
  • 標簽:

資源簡介

該源代碼是操作系統大作業,里面有作業要求,反正呢幾種內存替換算法,有SC,ESC,ARB,EARB

資源截圖

代碼片段和文件信息

#include?“stdio.h“
#include?
#include?
#include?
#define?FILENAME_LEN?35
#define?MAX_TRACE_LEN?1000000
#define?D?1
/*data?struct?which?is?use?for?read?trace?file*/
typedef?struct?Trace?{
unsigned?int?address;
char?mode;
}Trace;
/*data?struct?which?is?use?for?a?memory?informarion*/
typedef?struct?Memory{
unsigned?int?page;
char?mode;
int?refe;
int?arravl_time;
}Memory;
/*data?struct?which?is?use?for?page?queue*/
typedef?struct?Page?{
unsigned?int?page;
char?mode;
}Page;
/*
*?convert?a?hex?char?to?int?range?in?0~15
*?*/
int?c2i(char?ch);

/*
*?convert?a?hex?string?to?int
*?*/
int?hex2dec(char?*hex);


/*read?the?trace?file?to?Trace?array*/
void?read_trace_file(FILE?*in?Trace?*tint?*t_size);
/*calculate?the?ref?bit?of?m*/
int?refForEarb(Memory?m);


int?main(int?argcchar**?argv)
{
if?(argc?!=?5?&&?argc!=6)?{
printf(“argument?numbers?error!/n“);
return?-1;
}
//argument?convert
char?*in?=?argv[1];
int?pagesize?=?atoi(argv[2]);
int?numpage?=?atoi(argv[3]);
char?*algname?=?argv[4];
//variable
FILE?*trace?*detailed;
Trace?*t?=?(Trace*)malloc(MAX_TRACE_LEN*sizeof(Trace));?/*read?file?buffer*/
int?t_size;?/*trace?data?size*/
int?read_count?=?0?write_count?=?0;?/*reault?count*/

trace?=?fopen(in?“r“);
if?(trace?==?NULL)?{
printf(“open?file?error!/n“);
return?-1;
}
//read?trace?file
read_trace_file(tracet&t_size);
//init?page?queue?and?memory?array
Memory?*memory?=?malloc(numpage?*?sizeof(Memory));
Page?*pages?=?malloc(t_size?*?sizeof(Page));
int?mem_p=0;?/*current?memory?pointer*/
/*/init?page?queue*/
for?(int?i?=?0;?i? {
pages[i].page?=?t[i].address?/?pagesize; /*calculate?the?address?is?in?which?page*/
pages[i].mode?=?t[i].mode;
}
/*init?memory?array*/
for?(int?i=0;i {
memory[i].page?=?-1;
memory[i].refe?=?-1;?/*-1?is?no?page?in?this?memory*/
memory[i].mode?=?0;
memory[i].arravl_time?=?0;
}
free(t);
if?(strcmp(algname“SC“)==0)
{
char?de[FILENAME_LEN];
strcpy(de?in)?strcat(de?“_SC.detailed“);
detailed?=?fopen(de?“w“);
for?(int?i=0;i {
int?hit?=?0;?/*hit?flag*/
for?(int?j=0;j {
//HIT?
if?(memory[j].refe?!=-1?&&?memory[j].page?==?pages[i].page)
{//hit?this?page
fprintf(??detailed“HIT:??????page?%d\n“?pages[i].page);
/*if?hit?a?no?dirty?memory?change?memory?state*/
if?(memory[j].mode?==?‘R‘)
memory[j].mode?=?pages[i].mode;
memory[j].refe?=?1;
hit?=?1;
break;
}
}
if(hit==1)?/*if?hit?this?pageskip?to?next?page*/
continue;
/*if?not?hit?do?following?coderead_count?+1*/
fprintf(??detailed?“MISS:?????page?%d\n“?pages[i].page);
++read_count;
if?(memory[mem_p].refe?==?-1)
{/*if?the?memory?no?dataadd?page?to?this?memory*/
memory[mem_p].page?=?pages[i].page;
memor

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????13013??2018-10-11?16:10??memsim(1).c
?????文件???????10922??2018-10-11?16:46??memsim.c
?????目錄???????????0??2018-10-11?16:57??作業要求\
?????文件??????107404??2018-09-27?19:48??作業要求\example?file?總覽.pdf
?????目錄???????????0??2018-10-11?16:57??作業要求\example?input?files\
?????文件???????14340??2018-09-27?19:53??作業要求\example?input?files\.DS_Store
?????目錄???????????0??2018-10-11?16:57??作業要求\example?input?files\example?input?1/output?1\
?????文件????????6148??2018-09-27?19:45??作業要求\example?input?files\example?input?1/output?1\.DS_Store
?????文件?????????221??2018-09-27?19:41??作業要求\example?input?files\example?input?1/output?1\input1.trace
?????文件??????????68??2018-09-27?19:42??作業要求\example?input?files\example?input?1/output?1\input1_4096_8_ARB_2.expected
?????文件??????????68??2018-09-27?19:46??作業要求\example?input?files\example?input?1/output?1\input1_4096_8_EARB_2.expected
?????文件??????????68??2018-09-27?19:47??作業要求\example?input?files\example?input?1/output?1\input1_4096_8_ESC.expected
?????文件??????????68??2018-09-27?19:41??作業要求\example?input?files\example?input?1/output?1\input1_4096_8_SC.expected
?????文件?????????566??2018-09-27?19:43??作業要求\example?input?files\example?input?1/output?1\input1_ARB.detailed
?????文件?????????542??2018-09-27?19:43??作業要求\example?input?files\example?input?1/output?1\input1_EARB.detailed
?????文件?????????558??2018-09-27?19:43??作業要求\example?input?files\example?input?1/output?1\input1_ESC.detailed
?????文件?????????582??2018-09-27?19:43??作業要求\example?input?files\example?input?1/output?1\input1_SC.detailed
?????目錄???????????0??2018-10-11?16:57??作業要求\example?input?files\example?input?2/output?2\
?????文件????????6148??2018-09-27?19:51??作業要求\example?input?files\example?input?2/output?2\.DS_Store
?????文件?????????220??2018-09-27?19:49??作業要求\example?input?files\example?input?2/output?2\input2.trace
?????文件??????????68??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_4096_8_ARB_1.expected
?????文件??????????68??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_4096_8_EARB_1.expected
?????文件??????????68??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_4096_8_ESC.expected
?????文件??????????68??2018-09-27?19:49??作業要求\example?input?files\example?input?2/output?2\input2_4096_8_SC.expected
?????文件?????????513??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_ARB.detailed
?????文件?????????489??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_EARB.detailed
?????文件?????????529??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_ESC.detailed
?????文件?????????537??2018-09-27?19:50??作業要求\example?input?files\example?input?2/output?2\input2_SC.detailed
?????目錄???????????0??2018-10-11?16:57??作業要求\example?input?files\example?input?3_output?3\
?????文件????????6148??2018-09-27?19:52??作業要求\example?input?files\example?input?3_output?3\.DS_Store
?????文件?????????440??2018-09-27?19:51??作業要求\example?input?files\example?input?3_output?3\input3.trace
............此處省略57個文件信息

評論

共有 條評論