- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
[银行家算法原代码
实验代码
#include malloc.h
#include stdio.h
#include stdlib.h
#define alloclen sizeof(struct allocation)
#define maxlen sizeof(struct max)
#define avalen sizeof(struct available)
#define needlen sizeof(struct need)
#define finilen sizeof(struct finish)
#define pathlen sizeof(struct path)
struct allocation
{
int value;
struct allocation *next;
};
struct max
{
int value;
struct max *next;
};
struct available /*可用资源数*/
{
int value;
struct available *next;
};
struct need /*需求资源数*/
{
int value;
struct need *next;
};
struct path
{
int value;
struct path *next;
};
struct finish
{
int stat;
struct finish *next;
};
int main()
{
int row,colum,status=0,i,j,t,temp,processtest;
struct allocation *allochead,*alloc1,*alloc2,*alloctemp;
struct max *maxhead,*maxium1,*maxium2,*maxtemp;
struct available *avahead,*available1,*available2,*workhead,*work1,*work2,*worktemp,*worktemp1;
struct need *needhead,*need1,*need2,*needtemp;
struct finish *finihead,*finish1,*finish2,*finishtemp;
struct path *pathhead,*path1,*path2;
printf(\n请输入系统资源的种类数:);
scanf(%d,colum);
printf(请输入现时内存中的进程数:);
scanf(%d,row);
printf(请输入已分配资源矩阵:\n);
for(i=0;irow;i++)
{
for (j=0;jcolum;j++)
{
printf(请输入已分配给进程 p%d 的 %c 种系统资源:,i,A+j);
if(status==0)
{
allochead=alloc1=alloc2=(struct allocation*)malloc(alloclen);
alloc1-next=alloc2-next=NULL;
scanf(%d,allochead-value);
status++;
}
else
{
alloc2=(struct allocation *)malloc(alloclen);
scanf(%d,%d,alloc2-value);
if(status==1)
{
allochead-next=alloc2;
status++;
}
alloc1-next=alloc2;
alloc1=alloc2;
}
}
}
alloc2-next=NULL;
status=0;
printf(请输入最大需求矩阵:\n);
for(i=0;irow;i++)
{
for (j=0;jcolum;j++)
{
printf(请输入进程 p%d 种类 %c 系统资源最大需求:,i,A+j);
if(status==0)
{
maxhead=maxium1=maxium2=(struct max*)malloc(maxlen);
maxium1-next=maxium2-next=NULL;
scanf(%d,maxium1-value);
status++;
}
else
{
maxium2=(struc
文档评论(0)