cmm.h
来自「自己写的操作系统的实验:处理机调度模拟及内存分配模拟二合一小程序。」· C头文件 代码 · 共 50 行
H
50 行
#ifndef CMM_H
#define CMM_H
#define DEFAULT_SIZE 20
#define MM_TOTAL_SIZE 100
#define MM_MAX_SIZE 30
typedef unsigned int uint;
/*要使用Clist,需提供prep,nextp,和<(),>()*/
class Cmm
{
public:
uint begin;
uint size;
Cmm* prep;
Cmm* nextp;
public:
Cmm():begin(0),size(0),prep(NULL),nextp(NULL){}
/*p紧邻this,即p,this顺序*/
bool extent_front(Cmm* p)
{
if( p && this->begin==p->begin+p->size )
{
this->begin=p->begin;
this->size+=p->size;
return true;
}
return false;
}
/*this紧邻p,即this,p顺序*/
bool extent_back(Cmm* p)
{
if( p && p->begin==this->begin+this->size )
{
this->size+=p->size;
return true;
}
return false;
}
bool div(uint needs)
{
if( size<needs )
return false;
size-=needs;
begin+=needs;
return true;
}
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?