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

  • 大小: 937KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-05
  • 語言: C/C++
  • 標簽:

資源簡介

使用c++寫的對操作系統內存仿真算法,其中給了仿真要求和源代碼,共大家仿真參考

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#define?MAX_QUEUE_LEN?1000000
/*Event?struct*/
typedef?struct?Event?{
int?page;
char?mod;
}Event;
/*memory?struct*/
typedef?struct?Memory{
int?page;
char?mod;
int?ref;
int?age;?/*use?for?FIFO*/
}Memory;

/*convert?a?hex?string?to?decimal?int*/
int?Hex2Decimal(char?*hex);
/*init?memory?queue*/
Memory?*initMemory(int?NUMPAGES);
/*read?the?event?file?to?Event?queue*/
void?readEventsFile(char?*filename?Event?*eint?*events_sizeint?PAGESIZE);
/*SC?*/
void?SC(Event?*events?int?events_sizeint?NUMPAGES);
/*ESC?*/
void?ESC(Event?*events?int?events_size?int?NUMPAGE);
/*ARB?*/
void?ARB(Event?*events?int?events_size?int?NUMPAGEint?INTERVAL);
/*EARB?*/
void?EARB(Event?*events?int?events_size?int?NUMPAGE?int?INTERVAL);
/*print?result*/
void?printResult(int?events?int?read?int?write);
int?main(int?argcchar**?argv)
{
Event?*events?=?(Event*)malloc(MAX_QUEUE_LEN*sizeof(Event));
int?events_size;?
readEventsFile(argv[1]events&events_size?atoi(argv[2]));
if?(strcmp(argv[4]“SC“)==0)
SC(events?events_size?atoi(argv[3]));
else?if?(strcmp(argv[4]?“ESC“)?==?0)
ESC(events?events_size?atoi(argv[3]));
else?if?(strcmp(argv[4]?“ARB“)?==?0)
ARB(events?events_size?atoi(argv[3])?atoi(argv[5]));
else?if?(strcmp(argv[4]?“EARB“)?==?0)
EARB(events?events_size?atoi(argv[3])?atoi(argv[5]));
else?return?-1;
getchar();
}

void?readEventsFile(char?*filename?Event?*eint?*e_sizeint?PAGESIZE)
{
FILE?*fin?=?fopen(filename“r“);
char?s[100];
*e_size?=?0;
while?(fgets(s100fin))
{
if?(s[0]?==?‘R‘?||?s[0]?==?‘W‘)
{
char?tmp[9];
sscanf(s?“%c%s“?&e[*e_size].mod?tmp);
e[*e_size].page?=?Hex2Decimal(tmp)/PAGESIZE;
++(*e_size);
}
}
}

int?Hex2Decimal(char?*hex)
{
int?len?=?strlen(hex);
unsigned?num?=?0;
int?shift;

for?(int?i?=?0?temp?=?0;?i? {
char?c?=?*(hex?+?i);
if?(isalpha(c))
temp?=?isupper(c)???c?-?55?:?c?-?87;
if?(isdigit(c))
temp?=?c?-?‘0‘;
shift?=?(len?-?i?-?1)?*?4;
temp?=?temp?< num?=?num?|?temp;
}
return?num;
}

Memory?*?initMemory(int?NUMPAGES)
{
Memory?*m?=?malloc(NUMPAGES?*?sizeof(Memory));
for?(int?i?=?0;?i? {
m[i].page?=?-1;
m[i].ref?=?-1;?/*-1?is?no?page?in?this?memory*/
m[i].mod?=?0;
}
return?m;
}

void?SC(Event?*events?int?events_size?int?NUMPAGES)
{
int?disk_reads_count?=?0?disk_writes_count?=?0;?/*result?count*/
int?m_ptr?=?0;?/*current?memory?pointer*/
Memory?*memory?=?initMemory(NUMPAGES);
for?(int?i?=?0;?i? {
int?hit?=?0;?
for?(int?j?=?0;?j? {
if?(memory[j].ref?!=?-1?&&?memory[j].page?==?events[i].page)
{//hit?this?page
/*if?hit?a?no?dirty?memory?change?memory?state*/
memory[j].mod?=?memory[j].mod?==?‘R‘?events[i].mod:memory[j].m

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????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
?????文件??????????68??2018-09-27?19:51??作業要求\example?input?files\example?input?3_output?3\input3_4096_12_ARB_4.expected
............此處省略56個文件信息

評論

共有 條評論

相關資源