• 大小: 369KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: C++  操作系统  广工  

资源简介

包含首次适应分配算法,循环适应分配算法,最佳适应分配算法,伙伴系统分配算法,源代码流程图齐全

资源截图

代码片段和文件信息

#include
#include
#include
using namespace std;
//TEXTLOG为0时不输出记录文件,否则输出记录文件RunlogSM1.txt
#define TEXTLOG 1

struct AREA
{
int startaddress; //分区始址
int size; //分区大小
AREA *next;
};

AREA freehead; //空闲分区链头结点,size记录总空闲分区大小
AREA usehead; //应用分区链头结点,size记录总应用分区大小

char ch;

#if TEXTLOG
FILE *txtlog; //文本文档形式输出日志文件指针
#endif

int Alloc(int applyarea); //主存分配函数
void Combine(AREA *link int startaddress int size); //分区合并函数
bool Recycle(int startaddress int size); //主存回收函数
void Print(); //主存状态打印
bool Check(int x const bool canzero); //输入非负数检查

int main()
{
int size sadd tmp;
bool flag;
AREA *p;

#if TEXTLOG
txtlog = fopen(“RunlogSM1.txt“ “w“);
fprintf(txtlog “##############################################################\n“);
fprintf(txtlog “Memory variable regional management system - first adaptation (FF) algorithm\n“);
fprintf(txtlog “Programmer: Jobs Peng\n“);
fprintf(txtlog “Date: 25 / 5 / 2012\n“);
fprintf(txtlog “Note: The program has no input-error-debugger.\n“);
fprintf(txtlog “##############################################################\n\n“);
#endif

printf(“##############################################################\n“);
printf(“Memory variable regional management system - first adaptation (FF) algorithm\n“);
printf(“Programmer: Jobs Peng\n“);
printf(“Date: 25 / 5 / 2012\n“);
printf(“Note: The program has no input-error-debugger.\n“);
printf(“##############################################################\n\n“);

freehead.next = p = new (AREA);
printf(“How much memory: “);
do
{
scanf(“%d“ &p->size);
} while (!Check(p->size false));
freehead.size = p->size;
usehead.size = 0;
usehead.next = NULL;
p->next = NULL;

printf(“Memroy start address: “);
do
{
scanf(“%d“ &p->startaddress);
} while (!Check(p->startaddress true));

#if TEXTLOG
fprintf(txtlog “How much memory: %d\n“ p->size);
fprintf(txtlog “Memroy start address: %d\n“ p->startaddress);
#endif

printf(“\n\n***** README (Input Format) *****\n“);
printf(“Allocate memory: a XXX (\“XXX\“ replace by size)\n“);
printf(“Recycle memory: r YYY XXX (\“YYY\“ replace by startaddress\“XXX\“ replace by size)\n“);
printf(“Exit system: e\n“);
printf(“\nAttention! If input by any other format the system maybe error or broke.\n“);
printf(“*********************************\n\n“);

flag = true;
while (true)
{
if (flag)
{
Print();
flag = false;
}

printf(“You want (Use format to input): “);
do
{
ch = getchar();
} while (ch == ‘\n‘);

while (ch == ‘ ‘)
{
ch = getchar();


switch (ch)
{
case ‘a‘:
scanf(“%d“ &size);
if (!Check(size false))
{
break;
}

printf(“You want to allocate %d units of memory.\n“ size);
#if TEXTLOG
fprintf(txtlog “You want to allocate %d units of memory.\n“ size);
#endif
tmp = Alloc(size

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9515  2012-05-23 00:32  实验3\1空闲分区链-首次适应分配算法.cpp

     文件     266351  2012-05-23 00:32  实验3\1空闲分区链-首次适应分配算法(有记录文件输出).exe

     文件      10099  2012-05-23 00:33  实验3\2空闲分区链-循环适应分配算法.cpp

     文件     266351  2012-05-23 00:33  实验3\2空闲分区链-循环适应分配算法(有记录文件输出).exe

     文件       9684  2012-05-23 00:34  实验3\3空闲分区链-最佳适应分配算法.cpp

     文件     266351  2012-05-23 00:34  实验3\3空闲分区链-最佳适应分配算法(有记录文件输出).exe

     文件      14586  2012-05-23 00:35  实验3\4空闲分区链-伙伴系统分配算法.cpp

     文件     270447  2012-05-23 00:35  实验3\4空闲分区链-伙伴系统分配算法(有记录文件输出).exe

     文件          0  2013-01-09 17:34  实验3\RunlogSM1.txt

     文件       4411  2012-05-23 00:36  实验3\sample RunlogSM1.txt

     文件       4837  2012-05-23 00:37  实验3\sample RunlogSM2.txt

     文件       4410  2012-05-23 00:37  实验3\sample RunlogSM3.txt

     文件       5784  2012-05-23 00:37  实验3\sample RunlogSM4.txt

     文件      68096  2010-11-16 22:48  实验3\流程图1.vsd

     文件      68096  2010-11-16 22:49  实验3\流程图2.vsd

     文件      68096  2010-11-16 22:51  实验3\流程图3.vsd

     文件      73728  2010-11-16 23:00  实验3\流程图4.vsd

     目录          0  2013-01-09 17:34  实验3

----------- ---------  ---------- -----  ----

              1410842                    18


评论

共有 条评论