資源簡介
連續存儲空間管理仿真系統,操作系統,課設,存儲空間
代碼片段和文件信息
#include
#include
#include???????//?就是需要引用這個圖形庫
#include?
#include
#define?Count?7
#define?MAXSIZE?32
long?CLK;//模擬時鐘信號
int?a[]={881616163232};
////////////////////////////////////////////////////////////////////////////////////////////////
//PCB表的結構和初始化
typedef?struct?PCB{
int?sign;
int?data;
long?start;
int?time1;
struct?PCB?*next;
}*pcb;
typedef?struct?{
pcb?front;
pcb?rear;
}Pcb_head;
Pcb_head?ZZ;
void?Init_pcb()
{
ZZ.front=ZZ.rear=NULL;
int?datatime1name;
long?start;
srand((unsigned)time(NULL));??//確保隨機
int?num;
num=rand()%13+7;
for(int?j=1;j<=num;j++)
{
cout<<“進程名“<<“??“<<“申請內存“<<“??“<<“進入時間“<<“??“<<“持續時間“< cout<<“???“< data=rand()%1024+1;
cout< start=rand()%9+1;
cout< time1=rand()%9+1;?
cout<
pcb?o=(pcb)malloc(sizeof(PCB));
o->sign=j;
o->data=data;
o->time1=time1;
o->start=start;
if(ZZ.front==NULL)
ZZ.front=ZZ.rear=o;
ZZ.rear->next=o;
o->next=NULL;
ZZ.rear=o;
}
}
void?Init_pcb2()
{
ZZ.front=ZZ.rear=NULL;
int?datatime1name;
long?start;
srand((unsigned)time(NULL));??//確保隨機
int?num;
num=rand()%13+7;
for(int?j=1;j<=num;j++)
{
cout<<“進程名“<<“??“<<“申請內存“<<“??“<<“進入時間“<<“??“<<“持續時間“< cout<<“???“< data=rand()%32+1;
cout< start=rand()%6+1;
cout< time1=rand()%6+1;?
cout<
pcb?o=(pcb)malloc(sizeof(PCB));
o->sign=j;
o->data=data;
o->time1=time1;
o->start=start;
if(ZZ.front==NULL)
ZZ.front=ZZ.rear=o;
ZZ.rear->next=o;
o->next=NULL;
ZZ.rear=o;
}
}
/* while(1)
{
cout<<“輸入進程名、占用空間、起始時間、持續時間。(進程名輸入0退出)“< cin>>name;
if(name==0)
break;
cin>>data>>start>>time;
if(data>1024)
{
cout<<“所輸入的數值大于最大內存空間!!“< exit(-1);
}
pcb?o=(pcb)malloc(sizeof(PCB));
o->sign=name;
o->data=data;
o->time=time;
o->start=start;
if(ZZ.front==NULL)
ZZ.front=ZZ.rear=o;
ZZ.rear->next=o;
o->next=NULL;
ZZ.rear=o;
}*/
////////////////////////////
//后備等待隊列的定義與初始化
typedef?struct?node{
int?sign;
int?data;
int?time1;
struct?node?*next;
}*Queue;
typedef?struct{
Queue?front;
Queue?rear;
}Queue_head;
Queue_head?WW;
void?Init_queue()
{
WW.front=WW.rear=NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//就緒隊列和物理空間模擬隊列的定義與初始化
typedef?struct?Pnode{//內存塊結點
int?data;
int?sign;?????????//進程名
int?address;
int?time1;???//持續時間
struct?Pnode?*pre;??//指向前結點
struct?Pnode?*next;
}*QueuePtr;
typedef?struct{???????//頭結點
QueuePtr?front;
QueuePtr?rear;
}linkQueue;
linkQueue?FFFF_fenpei;
QueuePtr?FF_next_ff;
int?m_FF_Count=0;??//已分配的進程數
int?m_FF_Total=0;??//已分配的分區容量
void?Init_ff()
{
FF_fenpei.front=FF_fenpei.rear=NULL;
評論
共有 條評論