91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-31
  • 語言: 其他
  • 標簽: c??

資源簡介

操作系統 循環首次適應算法 回收內存 分配內存設計一個可變式分區分配的存儲管理方案。并模擬實現分區的分配和回收過程。

資源截圖

代碼片段和文件信息

#include
#include?
#include“stdlib.h“

#define?getpch(type)?(type*)malloc(sizeof(type))?
#define?SysSize??1000;

struct?LNode
{?
int?size;
?? char?*m_addr;
?? struct?LNode?*next;
?? struct?LNode?*front;
}*L;?/*L為頭指針*/

typedef?struct?LNode?LN;

LN?*find;?//查找節點
int?n?//表示空閑分區數量
fsize?//空閑分區總量
iniaddr;?//初始地址位置
char?*SysMemory;

void?PrintList()?/*打印內存存儲狀況*/
{
LN?*p;?int?i;
p=L;

printf(“\n空閑空間狀況(以%d為起始地址)\n“SysMemory);
printf(“\n空閑區號??長度??起始位置??相對位置\n“);
for(i=1;i<=n;i++)
{
printf(“%8d??%4d??%8d??%8d\n“ip->size?p->m_addr?(p->m_addr-SysMemory));
p=p->next;
}
printf(“\n“);
}


void?Initialize()??/*生成空閑分區鏈*/
{
int?a?=?SysSize;
L=getpch(LN);??/*生成一個表頭結點*/
L->next=L;
L->front=L;
SysMemory?=?(char*)?malloc(a);
L->m_addr=SysMemory;
L->size?=?SysSize;
fsize?=?L->size;
iniaddr?=?(int)L->m_addr;
n?=?1;
find?=?L;
PrintList();
printf(“\n空閑地址建立完成\n“);
}//?end?of?GetFree

void?NF_Assign(unsigned?size)/*循環首次適應算法的分配*/
{
LN?*p*t*s;

p=find;

if?(fsize?<=?0)
{
printf(“系統已無可用空間\n“);
return;
}
else?if?(size?>?fsize)
{
printf(“系統空間不足!分配不成功\n“);
return;
}
else?if?(size?<=?0)
{
printf(“大小不正確!\n“);
}

do
{
if(size?>?p->size)
{
p=p->next;
if(p==find)
{
printf(“沒有足夠大的空閑區分配!分配不成功\n“);?break; ???
}
}
else
{
p->size?-=?size;
p->m_addr?+=?size;
fsize?-=?size;
find=p->next;
if(p->size==0)
{
t?=?getpch(LN);
t=p->next;
t->front=p->front;
(t->front)->next=t;
n--;
if?(p?==?L)?{L=t;}
free(p);
find?=?t;
}
printf(“\n分配成功!\n“);
break;
}
}?while?(1);
}//?end?of?NF_Assign

void?AdrSpace(unsigned?size?unsigned?adr)
{
LN?*p*t;

if(adr+SysMemory?m_addr)
{
t?=?getpch(LN);

t->size=L->size;
t->m_addr?=?L->m_addr;
t->next?=?L->next;
L->m_addr?=?SysMemory?+?adr;
L->size?=?size;
L->next?=?t;
t->front?=?L;
for(p=L;p->next?!=?L;p=p->next){}
p->next?=?L;
L->front?=?p;
}
else
{
p=L;
do
{
if?(p->m_addr?>?SysMemory?+?adr)?break;
p?=?p->next;
}
while(p!=L);
t?=?getpch(LN);
t->size?=?size;
t->next?=?p;
t->front?=?p->front;
p->front->next?=?t;
t->m_addr?=?adr+SysMemory;
}
}


void?Recover(unsigned?size?unsigned?adr)??/*回收*/
{
LN?*

評論

共有 條評論