-
大小: 369KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-02
- 語言: 其他
- 標(biāo)簽: C++??操作系統(tǒng)??廣工??
資源簡介
包含首次適應(yīng)分配算法,循環(huán)適應(yīng)分配算法,最佳適應(yīng)分配算法,伙伴系統(tǒng)分配算法,源代碼流程圖齊全

代碼片段和文件信息
#include
#include
#include
using?namespace?std;
//TEXTLOG為0時(shí)不輸出記錄文件,否則輸出記錄文件RunlogSM1.txt
#define?TEXTLOG?1
struct?AREA
{
int?startaddress; //分區(qū)始址
int?size; //分區(qū)大小
AREA?*next;
};
AREA?freehead; //空閑分區(qū)鏈頭結(jié)點(diǎn),size記錄總空閑分區(qū)大小
AREA?usehead; //應(yīng)用分區(qū)鏈頭結(jié)點(diǎn),size記錄總應(yīng)用分區(qū)大小
char?ch;
#if?TEXTLOG
FILE?*txtlog; //文本文檔形式輸出日志文件指針
#endif
int?Alloc(int?applyarea); //主存分配函數(shù)
void?Combine(AREA?*link?int?startaddress?int?size); //分區(qū)合并函數(shù)
bool?Recycle(int?startaddress?int?size); //主存回收函數(shù)
void?Print(); //主存狀態(tài)打印
bool?Check(int?x?const?bool?canzero); //輸入非負(fù)數(shù)檢查
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(chǎn)‘:
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
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????9515??2012-05-23?00:32??實(shí)驗(yàn)3\1空閑分區(qū)鏈-首次適應(yīng)分配算法.cpp
?????文件?????266351??2012-05-23?00:32??實(shí)驗(yàn)3\1空閑分區(qū)鏈-首次適應(yīng)分配算法(有記錄文件輸出).exe
?????文件??????10099??2012-05-23?00:33??實(shí)驗(yàn)3\2空閑分區(qū)鏈-循環(huán)適應(yīng)分配算法.cpp
?????文件?????266351??2012-05-23?00:33??實(shí)驗(yàn)3\2空閑分區(qū)鏈-循環(huán)適應(yīng)分配算法(有記錄文件輸出).exe
?????文件???????9684??2012-05-23?00:34??實(shí)驗(yàn)3\3空閑分區(qū)鏈-最佳適應(yīng)分配算法.cpp
?????文件?????266351??2012-05-23?00:34??實(shí)驗(yàn)3\3空閑分區(qū)鏈-最佳適應(yīng)分配算法(有記錄文件輸出).exe
?????文件??????14586??2012-05-23?00:35??實(shí)驗(yàn)3\4空閑分區(qū)鏈-伙伴系統(tǒng)分配算法.cpp
?????文件?????270447??2012-05-23?00:35??實(shí)驗(yàn)3\4空閑分區(qū)鏈-伙伴系統(tǒng)分配算法(有記錄文件輸出).exe
?????文件??????????0??2013-01-09?17:34??實(shí)驗(yàn)3\RunlogSM1.txt
?????文件???????4411??2012-05-23?00:36??實(shí)驗(yàn)3\sample?RunlogSM1.txt
?????文件???????4837??2012-05-23?00:37??實(shí)驗(yàn)3\sample?RunlogSM2.txt
?????文件???????4410??2012-05-23?00:37??實(shí)驗(yàn)3\sample?RunlogSM3.txt
?????文件???????5784??2012-05-23?00:37??實(shí)驗(yàn)3\sample?RunlogSM4.txt
?????文件??????68096??2010-11-16?22:48??實(shí)驗(yàn)3\流程圖1.vsd
?????文件??????68096??2010-11-16?22:49??實(shí)驗(yàn)3\流程圖2.vsd
?????文件??????68096??2010-11-16?22:51??實(shí)驗(yàn)3\流程圖3.vsd
?????文件??????73728??2010-11-16?23:00??實(shí)驗(yàn)3\流程圖4.vsd
?????目錄??????????0??2013-01-09?17:34??實(shí)驗(yàn)3
-----------?---------??----------?-----??----
??????????????1410842????????????????????18
- 上一篇:meanshift跟蹤算法及源碼
- 下一篇:thinkcell 注冊程序,絕對好用
評論
共有 條評論