操作系统实验教程及linux和windows系统调用编程----张丽芬--清华大学出版社--部分程序源代码--第八章--主存空间的分配与回收--可变分区管理算法
freeblock[j+1].startaddress=middata.startaddress;
freeblock[j+1].size=middata.size;
freeblock[j+1].state=middata.state;
}
}
/////////////////////////////////////////////////////////////////
void print()
{
int i;
printf(" |................................|\n");
printf(" |address size state|\n");
printf(" |................................|\n");
for(i=0;i<N;i++)
{
printf(" |%3d %3d %3d |\n",
freeblock[i].startaddress,freeblock[i].size,freeblock[i].state);
printf(" |................................|\n");
}
}
void main()
{
int applyarea,start,i;
char end;
printf("\n is there any job request memory? y or n:");
while((end=getchar())=='y')
{
printf("at first the free memory is this:\n:");
adjust();
print();
printf("inpur request memory is this:\n");
scanf("%d",&applyarea);
start=alloc( applyarea);
adjust();
printf("after allocation, the free memory is this:\n:");
print();
if(start==-1)
printf("there is no fit memory ,please wait!\n:");
else
printf("job's memory start address is:%d\n:",start);
printf(" job size is:%d\n:",applyarea);
printf("job is running.\n:" );
printf("job is terminated.\n:" );
for(i=1;i<1000;i++);
setfr
ee();
adjust();
print();
printf("is there any job that is waiting?y\n:" );
end=getchar();
}
//}
}