操作系统原理与实验——实验十三多道批处理作业调度(作业不可移动),操作系统实验,多道批处理作业调度(作业不可移动)原理与操作指南

马肤

温馨提示:这篇文章已超过444天没有更新,请注意相关的内容是否还可用!

摘要:本次实验是关于操作系统中的多道批处理作业调度,特点是作业不可移动。实验旨在探究在固定作业顺序下,操作系统如何高效调度资源,实现多个作业的并行处理。通过本次实验,可以深入理解作业调度的原理及其在操作系统中的实际应用,提高操作系统性能优化的能力。

操作系统原理与实验——实验十三多道批处理作业调度(作业不可移动),操作系统实验,多道批处理作业调度(作业不可移动)原理与操作指南 第1张

关键代码

#include
#include
#include
typedef struct  data{
    int hour;//当前小时
    int min;//当前分钟
}time;
struct node{
    char name[20];//进程名
    time arrive;//到达就绪队列时间
    int zx;//执行时间(预期时间)
    int size;
    int tai;
    int flag;
    time zhuangru; 
    time start;//开始执行时间(进程调度)
    time finish;//执行完成时间
    int zz;//周转时间=完成时间-到达就绪队列时间
    float zzxs;//带权周转时间系数=周转时间/执行时间
    struct node* next;
};
//内存结构体
typedef struct memory_node{
    int size; //内存大小
    int address; //内存始址
} memoryNode;
memoryNode memory;
//分区结构体
struct link_node{
    int size;//分区大小
    int address; //分区始址
    char flag[20]; //分区状态,空闲或者占用作业名
    struct link_node *next;
};
int resource;
//函数名:in参数:无
node* in(){
//函数功能:输入访问序列信息
	int n;
	node *q,*head;
	head = NULL; 
	printf("请输入内存大小:");
	scanf("%d",&memory.size);
	printf("请输入起始地址大小为:");
	scanf("%d",&memory.address);
	printf("请输入磁带机资源:");
	scanf("%d",&resource); 
	printf("请输入进程数量:");
	scanf("%d",&n);
	printf("请输入进程的参数:\n"); 
	for(int i=0;iflag = 0;
		p->next = NULL;
		scanf("%s %d:%d %d分钟 %dK %d台",&p->name,&p->arrive.hour,&p->arrive.min,&p->zx,&p->size,&p->tai);
		if(head == NULL)
		{
			head = p;
			q = p;
		} 
		else
		{
			q->next = p;
			q = p;
		}
	}
	return head;
}
void output(node *p) {
    //函数功能:按进程执行顺序分别输出每个进程全部结果信息和系统平均时间
   int sum=0,count=0; 
   float sum1=0; 
   printf("\n模拟进程FCFS调度过程输出结果:\n作业名   到达时间   执行时间(分钟)    装入时间   开始时间   完成时间  周转时间(分钟)  带权周转系数\n");
   while(p!=NULL)
   {
    	printf("%5s ",p->name);
    	printf("%5d:%02d ",p->arrive.hour,p->arrive.min);
    	printf("%8d(分钟) ",p->zx);
    	printf("%14d:%02d ",p->zhuangru.hour,p->zhuangru.min);
    	printf("%6d:%02d ",p->start.hour,p->start.min);
    	printf("%7d:%02d ",p->finish.hour,p->finish.min);
    	printf("%7d ",p->zz);
    	printf("%20.2f\n",p->zzxs);
    	sum=sum+p->zz;
    	sum1=sum1+p->zzxs;
    	count++;
    	p=p->next;
   }
   printf("系统平均周转时间为:%.2f\n",sum*1.0/count);
   printf("系统平均带权周转系数为:%.2f\n\n",sum1/count);
}
//函数名:FCFS参数:无
void FCFS(){
//函数功能:调用先来先服务算法
	printf("\n***********FCFS多道批处理作业调度***********\n");
	node *head = in();
	node *h,*q;
	h = NULL;
	q = head;
	while(q!=NULL)
	{
		node *p = (node *)malloc(sizeof(node));
		*p = *q;
		p->next = NULL;
		if(h == NULL)
		{
			h = p;
		}
		else
		{
			node *a = h,*b;
			while(a!=NULL)
			{
				if(p->arrive.hour*60+p->arrive.minarrive.hour*60+a->arrive.min)
				break;
				b = a;
				a = a->next;
			}
			if(a == h)
			{
				p->next = h;
				h = p;
			}
			else
			{
				p->next = a;
				b->next = p;
			}
		}
		q = q->next; 
	}
	
	time now;
	now.hour = 0;
	now.min = 0;
	int qaq = 0,available = resource;
	q = h;
	node *duilie = NULL,*flow,*flagh;
	node *k,*flowk,*KK=NULL; 
	link_node *wfp,*yfp,*bl1,*bl2,*bl1pre,*bl2pre;
	wfp = NULL;
	yfp = NULL;
	
	link_node* i = (link_node*)malloc(sizeof(link_node));
	i->address = memory.address;
	i->flag[0] = '

实验结果

'; i->size = memory.size; i->next = NULL; wfp = i; bl1 = wfp; while(h!=NULL) { flagh = h; //每一次大循环都找在自己执行完的时间内并且符合条件的 摘下来 //大循环每次末尾都回收第一个 q = h; if(duilie==NULL) { h = q->next; q->next = NULL; duilie = q; flow = duilie; if(duilie->arrive.hour*60+duilie->arrive.min>now.hour*60+now.min) { now.hour = duilie->arrive.hour; now.min = duilie->arrive.min; } duilie->start.hour = now.hour; duilie->start.min = now.min; duilie->zhuangru.hour = now.hour; duilie->zhuangru.min = now.min; link_node *i = (link_node *)malloc(sizeof(link_node));//分配给作业的结点 i->address = wfp->address; strcpy(i->flag,q->name); i->size = q->size; i->next = NULL; available -=q->tai; if(wfp->size==q->size)//修改未分配表 !!!!! { wfp = NULL; } else { wfp->address = wfp->address + q->size; wfp->size = wfp->size - q->size; } //修改已分配表 yfp = i; } //如果不是第一个,则遍历去找符合条件的 node *hh = h,*hhpre; bl1 = wfp; while(hh!=NULL) { bl1 = wfp; while(bl1!=NULL) { if(hh->sizesize) break; bl1pre = bl1; bl1=bl1->next; } if(hh->arrive.hour*60+hh->arrive.minstart.hour*60+duilie->start.min+duilie->zx&&bl1!=NULL&&available-hh->tai>=0) { //满足条件 hh->start.hour = duilie->start.hour + (duilie->start.min + duilie->zx )/60; hh->start.min = (duilie->start.min + duilie->zx )%60; hh->zhuangru.hour = now.hour; hh->zhuangru.min = now.min; available -=hh->tai; link_node *i = (link_node *)malloc(sizeof(link_node));//分配给作业的结点 i->address = bl1->address; strcpy(i->flag,hh->name); i->size = hh->size; i->next = NULL; if(bl1 == wfp)//修改未分配表 { if(bl1->size==hh->size) { wfp = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } else { if(bl1->size==hh->size) { bl1pre->next = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } if(yfp == NULL) { yfp = i; } else { i->next = yfp; yfp = i; } if(hh==h) { h=hh->next; hh->next = NULL; if(duilie == NULL) { duilie = hh; flow = hh; } else { flow->next = hh; flow = hh; } hh = h; } else { hhpre->next = hh->next; hh->next = NULL; if(duilie == NULL) { duilie = hh; flow = hh; } else { flow->next = hh; flow = hh; } hh = hhpre->next; } } else { //不满足条件—————— 空间不满足 or 磁带机不满足 hhpre = hh; hh=hh->next; } } //回收资源 k=duilie; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai; bl2 = yfp; while(bl2!=NULL) { if(strcmp(bl2->flag,duilie->name)==0) break; bl2pre = bl2; bl2 = bl2->next; } if(bl2 == yfp) { yfp = bl2->next; } else { bl2pre->next = bl2->next; } bl2->flag[0] = '

实验总结

'; bl2->next = NULL; bl1 = wfp; if(wfp==NULL) { wfp = bl2; } else while(bl1!=NULL) { if((bl2->address+bl2->size)address)//插头 { if(bl2->address+bl2->sizeaddress) { bl2->flag[0] = '

tips:本题思路

'; bl2->next = wfp; wfp = bl2; } else { wfp->address = bl2->address; wfp->size = wfp->size + bl2->size; free(bl2); } break; } else if(bl1->next == NULL&&bl2->address>=bl1->address+bl1->size)//插尾 { if(bl2->address>bl1->address+bl1->size) { bl2->flag[0] = ''; bl2->next = NULL; bl1->next = bl2; } else { bl1->size = bl1->size + bl2->size; free(bl2); } break; } else if(bl2->address+bl2->sizeaddress)//插中间 { if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->sizeaddress)//没有上邻,没有下邻 { bl2->next = bl1; bl1->next = bl2; } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->sizeaddress)//有上邻,没有下邻 { bl1pre->size = bl1pre->size + bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->size==bl1->address)//没有上邻,有下邻 { bl1->address = bl2->address; bl1->size = bl1->size +bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->size==bl1->address)//有下邻,有下邻 { bl1pre->size = bl1pre->size + bl1->size + bl2->size; bl1pre->next = bl1->next; free(bl1); free(bl2); } break; } bl1pre = bl1; bl1 = bl1->next; } duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } while(duilie!=NULL)//h==NULL但是duilie不等于NULL { k=duilie; k->start.hour = now.hour; k->start.min = now.min; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai;memory.size +=k->size; duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } output(KK); } //函数名:SSTF参数:无 void SPF(){ //函数功能:调用短进程优先调度算法 printf("\n***********SPF多道批处理作业调度***********\n"); node *head = in(); node *h,*q,*H; h = NULL; q = head; H = q; q = q->next; while(q!=NULL) { node *p = (node *)malloc(sizeof(node)); *p = *q; p->next = NULL; if(h == NULL) { h = p; } else { node *a = h,*b; while(a!=NULL) { if(p->zxzx) break; b = a; a = a->next; } if(a == h) { p->next = h; h = p; } else { p->next = a; b->next = p; } } q = q->next; } H->next = h; h = H; time now; now.hour = 0; now.min = 0; int qaq = 0,available = resource; q = h; node *duilie = NULL,*flow,*flagh; node *k,*flowk,*KK=NULL; link_node *wfp,*yfp,*bl1,*bl2,*bl1pre,*bl2pre; wfp = NULL; yfp = NULL; link_node* i = (link_node*)malloc(sizeof(link_node)); i->address = memory.address; i->flag[0] = ''; i->size = memory.size; i->next = NULL; wfp = i; bl1 = wfp; while(h!=NULL) { flagh = h; //每一次大循环都找在自己执行完的时间内并且符合条件的 摘下来 //大循环每次末尾都回收第一个 q = h; if(duilie==NULL) { h = q->next; q->next = NULL; duilie = q; flow = duilie; if(duilie->arrive.hour*60+duilie->arrive.min>now.hour*60+now.min) { now.hour = duilie->arrive.hour; now.min = duilie->arrive.min; } duilie->start.hour = now.hour; duilie->start.min = now.min; duilie->zhuangru.hour = now.hour; duilie->zhuangru.min = now.min; link_node *i = (link_node *)malloc(sizeof(link_node));//分配给作业的结点 i->address = wfp->address; strcpy(i->flag,q->name); i->size = q->size; i->next = NULL; available -=q->tai; if(wfp->size==q->size)//修改未分配表 !!!!! { wfp = NULL; } else { wfp->address = wfp->address + q->size; wfp->size = wfp->size - q->size; } //修改已分配表 yfp = i; } //如果不是第一个,则遍历去找符合条件的 node *hh = h,*hhpre; bl1 = wfp; while(hh!=NULL) { bl1 = wfp; while(bl1!=NULL) { if(hh->sizesize) break; bl1pre = bl1; bl1=bl1->next; } if(hh->arrive.hour*60+hh->arrive.minstart.hour*60+duilie->start.min+duilie->zx&&bl1!=NULL&&available-hh->tai>=0) { //满足条件 hh->start.hour = duilie->start.hour + (duilie->start.min + duilie->zx )/60; hh->start.min = (duilie->start.min + duilie->zx )%60; hh->zhuangru.hour = now.hour; hh->zhuangru.min = now.min; available -=hh->tai; link_node *i = (link_node *)malloc(sizeof(link_node));//分配给作业的结点 i->address = bl1->address; strcpy(i->flag,hh->name); i->size = hh->size; i->next = NULL; if(bl1 == wfp)//修改未分配表 { if(bl1->size==hh->size) { wfp = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } else { if(bl1->size==hh->size) { bl1pre->next = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } if(yfp == NULL) { yfp = i; } else { i->next = yfp; yfp = i; } if(hh==h) { h=hh->next; hh->next = NULL; if(duilie == NULL) { duilie = hh; flow = hh; } else { flow->next = hh; flow = hh; } hh = h; } else { hhpre->next = hh->next; hh->next = NULL; if(duilie == NULL) { duilie = hh; flow = hh; } else { flow->next = hh; flow = hh; } hh = hhpre->next; } } else { //不满足条件——————>空间不满足 or 磁带机不满足 hhpre = hh; hh=hh->next; } } //回收资源 k=duilie; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai; bl2 = yfp; while(bl2!=NULL) { if(strcmp(bl2->flag,duilie->name)==0) break; bl2pre = bl2; bl2 = bl2->next; } if(bl2 == yfp) { yfp = bl2->next; } else { bl2pre->next = bl2->next; } bl2->flag[0] = ''; bl2->next = NULL; bl1 = wfp; if(wfp==NULL) { wfp = bl2; } else while(bl1!=NULL) { if((bl2->address+bl2->size)address)//插头 { if(bl2->address+bl2->sizeaddress) { bl2->flag[0] = ''; bl2->next = wfp; wfp = bl2; } else { wfp->address = bl2->address; wfp->size = wfp->size + bl2->size; free(bl2); } break; } else if(bl1->next == NULL&&bl2->address>=bl1->address+bl1->size)//插尾 { if(bl2->address>bl1->address+bl1->size) { bl2->flag[0] = ''; bl2->next = NULL; bl1->next = bl2; } else { bl1->size = bl1->size + bl2->size; free(bl2); } break; } else if(bl2->address+bl2->sizeaddress)//插中间 { if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->sizeaddress)//没有上邻,没有下邻 { bl2->next = bl1; bl1->next = bl2; } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->sizeaddress)//有上邻,没有下邻 { bl1pre->size = bl1pre->size + bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->size==bl1->address)//没有上邻,有下邻 { bl1->address = bl2->address; bl1->size = bl1->size +bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->size==bl1->address)//有下邻,有下邻 { bl1pre->size = bl1pre->size + bl1->size + bl2->size; bl1pre->next = bl1->next; free(bl1); free(bl2); } break; } bl1pre = bl1; bl1 = bl1->next; } duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } while(duilie!=NULL)//h==NULL但是duilie不等于NULL { k=duilie; k->start.hour = now.hour; k->start.min = now.min; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai;memory.size +=k->size; duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } output(KK); } //函数名:Elevator参数:无 void HRRF(){ //函数功能:调用电梯调度算法 printf("\n***********HRRF多道批处理作业调度***********\n"); node *head = in(); node *h,*q; h = NULL; q = head; while(q!=NULL) { node *p = (node *)malloc(sizeof(node)); *p = *q; p->next = NULL; if(h == NULL) { h = p; } else { node *a = h,*b; while(a!=NULL) { if(p->arrive.hour*60+p->arrive.minarrive.hour*60+a->arrive.min) break; b = a; a = a->next; } if(a == h) { p->next = h; h = p; } else { p->next = a; b->next = p; } } q = q->next; } time now; now.hour = 0; now.min = 0; int qaq = 0,available = resource,flag=0; q = h; node *duilie = NULL,*flow,*flagh; node *k,*flowk,*KK=NULL; link_node *wfp,*yfp,*bl1,*bl2,*bl1pre,*bl2pre; wfp = NULL; yfp = NULL; link_node* i = (link_node*)malloc(sizeof(link_node)); i->address = memory.address; i->flag[0] = ''; i->size = memory.size; i->next = NULL; wfp = i; bl1 = wfp; while(h!=NULL) { flagh = h; //每一次大循环都找在自己执行完的时间内并且符合条件的 摘下来 //大循环每次末尾都回收第一个 q = h; if(flag==0) { flag=1; node *first = h,*b = h; while(b!=NULL) { if(b->arrive.hour*60+b->arrive.minarrive.hour*60+first->arrive.min) first = b; b = b->next; } b = h; while(b!=NULL) { if(b->next == first) break; b = b->next; } if(first == h) { h = first->next; first->next = NULL; duilie = first; } else { b->next = first->next; first->next = NULL; duilie = first; } flow = duilie; now.hour = duilie->arrive.hour; now.min = duilie->arrive.min; duilie->start.hour = now.hour; duilie->start.min = now.min; duilie->zhuangru.hour = now.hour; duilie->zhuangru.min = now.min; now.hour = duilie->start.hour + (duilie->start.min + duilie->zx)/60; now.min = (duilie->start.min + duilie->zx)%60; duilie->finish.hour = now.hour; duilie->finish.min = now.min; duilie->zz = duilie->finish.hour*60 + duilie->finish.min - (duilie->arrive.hour*60 + duilie->arrive.min); duilie->zzxs = duilie->zz*1.0/duilie->zx; duilie = duilie->next; KK = flow; flowk = KK; } q = h; node *xyb=NULL; while(q!=NULL) { node *p = (node *)malloc(sizeof(node)); *p = *q; p->next = NULL; if(xyb == NULL) { xyb = p; } else { node *a = xyb,*b; while(a!=NULL) { if((now.hour*60+now.min-q->arrive.hour*60-q->arrive.min+q->zx)*1.0/q->zx>(now.hour*60+now.min-a->arrive.hour*60-a->arrive.min+a->zx)*1.0/a->zx) break; b = a; a = a->next; } if(a == xyb) { p->next = xyb; xyb = p; } else { p->next = a; b->next = p; } } q = q->next; } //如果不是第一个,则遍历去找符合条件的 node *hh = xyb,*hhpre; bl1 = wfp; while(hh!=NULL) { bl1 = wfp; while(bl1!=NULL) { if(hh->sizesize) break; bl1pre = bl1; bl1=bl1->next; } if(bl1!=NULL&&available-hh->tai>=0) { //满足条件 available -=hh->tai; link_node *i = (link_node *)malloc(sizeof(link_node));//分配给作业的结点 i->address = bl1->address; strcpy(i->flag,hh->name); i->size = hh->size; i->next = NULL; if(bl1 == wfp)//修改未分配表 { if(bl1->size==hh->size) { wfp = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } else { if(bl1->size==hh->size) { bl1pre->next = bl1->next; free(bl1); } else { bl1->address = bl1->address + hh->size; bl1->size = bl1->size - hh->size; } } if(yfp == NULL) { yfp = i; } else { i->next = yfp; yfp = i; } node *xybh = h,*xybhpre; while(xybh!=NULL) { if(strcmp(xybh->name,hh->name) == 0) { xybh->zhuangru.hour = now.hour; xybh->zhuangru.min = now.min; break; } xybhpre = xybh; xybh = xybh->next; } if(xybh == h) { h = h->next; xybh->next = NULL; if(duilie == NULL) { duilie = xybh; flow = xybh; } else { flow->next = xybh; flow = xybh; } } else { xybhpre->next = xybh->next; xybh->next = NULL; if(duilie == NULL) { duilie = xybh; flow = xybh; } else { flow->next = xybh; flow = xybh; } } } //否则不满足条件——————> 空间不满足 or 磁带机不满足 hh = hh->next; } //回收资源 k=duilie; k->start.hour = now.hour; k->start.min = now.min; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai; bl2 = yfp; while(bl2!=NULL) { if(strcmp(bl2->flag,duilie->name)==0) break; bl2pre = bl2; bl2 = bl2->next; } if(bl2 == yfp) { yfp = bl2->next; } else { bl2pre->next = bl2->next; } bl2->flag[0] = ''; bl2->next = NULL; bl1 = wfp; if(wfp==NULL) { wfp = bl2; } else while(bl1!=NULL) { if((bl2->address+bl2->size)address)//插头 { if(bl2->address+bl2->sizeaddress) { bl2->flag[0] = ''; bl2->next = wfp; wfp = bl2; } else { wfp->address = bl2->address; wfp->size = wfp->size + bl2->size; free(bl2); } break; } else if(bl1->next == NULL&&bl2->address>=bl1->address+bl1->size)//插尾 { if(bl2->address>bl1->address+bl1->size) { bl2->flag[0] = ''; bl2->next = NULL; bl1->next = bl2; } else { bl1->size = bl1->size + bl2->size; free(bl2); } break; } //else if() else if(bl2->address+bl2->sizeaddress)//插中间 { if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->sizeaddress)//没有上邻,没有下邻 { bl2->next = bl1; bl1->next = bl2; } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->sizeaddress)//有上邻,没有下邻 { bl1pre->size = bl1pre->size + bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->sizeaddress&&bl2->address+bl2->size==bl1->address)//没有上邻,有下邻 { bl1->address = bl2->address; bl1->size = bl1->size +bl2->size; free(bl2); } else if(bl1pre->address+bl1pre->size==bl2->address&&bl2->address+bl2->size==bl1->address)//有下邻,有下邻 { bl1pre->size = bl1pre->size + bl1->size + bl2->size; bl1pre->next = bl1->next; free(bl1); free(bl2); } break; } bl1pre = bl1; bl1 = bl1->next; } duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } while(duilie!=NULL)//h==NULL但是duilie不等于NULL { k=duilie; k->start.hour = now.hour; k->start.min = now.min; k->finish.hour = k->start.hour+(k->start.min+k->zx)/60; k->finish.min = (k->start.min + k->zx)%60; k->zz = k->finish.hour*60 + k->finish.min - (k->arrive.hour*60 + k->arrive.min); k->zzxs = k->zz*1.0/k->zx; now.hour = k->finish.hour; now.min = k->finish.min; available +=k->tai;memory.size +=k->size; duilie = duilie->next; if(KK==NULL) { KK=k; flowk = k; k->next = NULL; } else { flowk->next = k; flowk = k; k->next = NULL; } } output(KK); } //函数名:Out参数:无 void Out(){ //函数功能:输出选项菜单 printf("***************多道批处理作业调度***************\n"); printf(" * 1.先来先服务调度算法(FCFS) *\n"); printf(" * 2.最短作业优先算法(SPF) *\n"); printf(" * 3.响应比最高者优先算法(HRRF) *\n"); printf(" * 0.退出 *\n"); printf(" 请输入选项[ ]\b\b"); } int main() { while (1) { Out();//给出选项 int c; scanf("%d", &c); switch (c){//选择算法 case 1:FCFS(); break; case 2:SPF(); break; case 3:HRRF(); break; default:printf("\n调度结束!"); exit(1); } } return 0; }

操作系统原理与实验——实验十三多道批处理作业调度(作业不可移动),操作系统实验,多道批处理作业调度(作业不可移动)原理与操作指南 第2张

①处理单链表还是不熟练;

②对操作哪个单链表模糊,导致结果错误;

③C语言没有return不报错;

④p=q不等价与*p=*q;

⑤宏观上并行,微观上串行;先释放在申请。

操作系统原理与实验——实验十三多道批处理作业调度(作业不可移动),操作系统实验,多道批处理作业调度(作业不可移动)原理与操作指南 第3张


0
收藏0
文章版权声明:除非注明,否则均为VPS857原创文章,转载或复制请以超链接形式并注明出处。

相关阅读

  • 【研发日记】Matlab/Simulink自动生成代码(二)——五种选择结构实现方法,Matlab/Simulink自动生成代码的五种选择结构实现方法(二),Matlab/Simulink自动生成代码的五种选择结构实现方法详解(二)
  • 超级好用的C++实用库之跨平台实用方法,跨平台实用方法的C++实用库超好用指南,C++跨平台实用库使用指南,超好用实用方法集合,C++跨平台实用库超好用指南,方法与技巧集合
  • 【动态规划】斐波那契数列模型(C++),斐波那契数列模型(C++实现与动态规划解析),斐波那契数列模型解析与C++实现(动态规划)
  • 【C++】,string类底层的模拟实现,C++中string类的模拟底层实现探究
  • uniapp 小程序实现微信授权登录(前端和后端),Uniapp小程序实现微信授权登录全流程(前端后端全攻略),Uniapp小程序微信授权登录全流程攻略,前端后端全指南
  • Vue脚手架的安装(保姆级教程),Vue脚手架保姆级安装教程,Vue脚手架保姆级安装指南,Vue脚手架保姆级安装指南,从零开始教你如何安装Vue脚手架
  • 如何在树莓派 Raspberry Pi中本地部署一个web站点并实现无公网IP远程访问,树莓派上本地部署Web站点及无公网IP远程访问指南,树莓派部署Web站点及无公网IP远程访问指南,本地部署与远程访问实践,树莓派部署Web站点及无公网IP远程访问实践指南,树莓派部署Web站点及无公网IP远程访问实践指南,本地部署与远程访问详解,树莓派部署Web站点及无公网IP远程访问实践详解,本地部署与远程访问指南,树莓派部署Web站点及无公网IP远程访问实践详解,本地部署与远程访问指南。
  • vue2技术栈实现AI问答机器人功能(流式与非流式两种接口方法),Vue2技术栈实现AI问答机器人功能,流式与非流式接口方法探究,Vue2技术栈实现AI问答机器人功能,流式与非流式接口方法详解
  • 发表评论

    快捷回复:表情:
    评论列表 (暂无评论,0人围观)

    还没有评论,来说两句吧...

    目录[+]

    取消
    微信二维码
    微信二维码
    支付宝二维码