1 / 22
文档名称:

电梯调度算法源代码.doc

格式:doc   大小:59KB   页数:22页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

电梯调度算法源代码.doc

上传人:资料分享 2018/5/16 文件大小:59 KB

下载得到文件列表

电梯调度算法源代码.doc

相关文档

文档介绍

文档介绍:#include <>
#include <>
#include <>
#include <>
typedef struct _proc
{
char name[32]; /*定义进程名称*/
int team; /*定义柱面号*/
int ci; /*定义磁道面号*/
int rec; /*定义记录号*/
struct _proc *prior;
struct _proc *next;
}PROC;
PROC *g_head=NULL,*g_curr=NULL,*local;
int record=0;
int yi=1;
void init()
{
PROC *p; /*初始化链表(初始I/O表)*/
g_head = (PROC*)malloc(sizeof(PROC));
g_head->next = NULL;
g_head->prior = NULL;
p = (PROC*)malloc(sizeof(PROC));
strcpy(p->name, "P1");
p->team=100;
p->ci=10;
p->rec=1;
p->next = NULL;
p->prior = g_head;
g_head->next = p;
g_curr=g_head->next;
p = (PROC*)malloc(sizeof(PROC));
strcpy(p->name, "P2");
p->team=30;
p->ci=5;
p->rec=5;
p->next = NULL;
p->prior = g_curr;
g_curr->next = p;
g_curr=p;
p = (PROC*)malloc(sizeof(PROC));
strcpy(p->name, "P3");
p->team=40;
p->ci=2;
p->rec=4;
p->next = NULL;
p->prior = g_curr;
g_curr->next = p;
g_curr=p;
p = (PROC*)malloc(sizeof(PROC));
strcpy(p->name, "P4");
p->team=85;
p->ci=7;
p->rec=3;
p->next = NULL;
p->prior = g_curr;
g_curr->next = p;
g_curr=p;
p = (PROC*)malloc(sizeof(PROC));
strcpy(p->name, "P5");
p->team=60;
p->ci=8;
p->rec=4;
p->next = NULL;
p->prior = g_curr;
g_curr->next = p;
g_curr=g_head->next;
local = (PROC*)malloc(sizeof(PROC)); /*选中进程*/
strcpy(local->name, "P0");
local->team=0;
local->ci=0;
local->rec=0;
local->next=NULL;
local->prior=NULL;
}
void PrintInit() /*打印I/O表*/
{
PROC *t = g_head->next;
printf("-------------------------------------\n");
printf(" ---------I/O LIST---------\n");
printf(" process team ci rec \n");
while(t!=NULL)
{
printf("%4s %8d %8d %5d\n", t->name, t->team, t->ci, t->rec );
t = t->next;
}
printf("\n\nCurrent process is :\n");
printf("------------------------------\n\n");
printf(" process team ci rec \n");
printf("%4s %8d %8d %5d\n", local->name, local->team, local->ci, local->rec );
switch(yi)
{
case 1:{printf("current direction is UP\n");break;}
case 0:{printf("curr