亲宝软件园·资讯

展开

短进程作业调度 java实现操作系统的短进程作业调度示例分享

人气:0
想了解java实现操作系统的短进程作业调度示例讲解的相关内容吗,在本文为您仔细讲解短进程作业调度的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:java,操作系统,短进程,作业调度,下面大家一起来学习吧。

复制代码 代码如下:

package com;

import java.util.Arrays;
 public class sjf {

  public static void main(String[] args) {
   sjf SJF=new sjf();
   SJF.fun1();
  }

  int starttime;
  int arrivetime;
  int finishtime;
  int zhouzhuan;
  

  public void fun1(){

   int a[]={1,3,2};
   int c[]=new int[3];
   for (int i = 0; i < 3; i++) {
    c[i]=a[i];
   }
   Arrays.sort(c);
   finishtime=a[0];
   int[]d={0,3,3};
   int zhouzhuan=finishtime-arrivetime;
   float weightzhouzhuan=(float)zhouzhuan/a[0];//位权周转时间为周转时间h
   System.out.println("开始时间"+starttime+"\t"+"到达时间"
     +arrivetime+"\t"+"完成时间"+finishtime+"\t"+"周转时间"+zhouzhuan+"\t"+"服务时间"+a[0]+"\t"+"带权周转时间"+weightzhouzhuan);

   for (int i = 1; i < 3; i++) {
    arrivetime=d[i];
    if(finishtime>=arrivetime){
     starttime=finishtime;
     finishtime+=c[i];
     zhouzhuan=finishtime-arrivetime;
     weightzhouzhuan=(float)zhouzhuan/c[i];
     System.out.println("开始时间"+starttime+"\t"+"到达时间"
       +arrivetime+"\t"+"完成时间"+finishtime+"\t"+"周转时间"+zhouzhuan+"\t"+"服务时间"+c[i]+"\t"+"带权周转时间"+weightzhouzhuan);
    }else{

     Arrays.sort(c);
     starttime=arrivetime;
     finishtime=starttime+c[i];
     zhouzhuan=finishtime-arrivetime;
     weightzhouzhuan=(float)zhouzhuan/c[i];
     System.out.println("开始时间"+starttime+"\t"+"到达时间"
       +arrivetime+"\t"+"完成时间"+finishtime+"\t"+"周转时间"+zhouzhuan+"\t"+"服务时间"+c[i]+"\t"+"带权周转时间"+weightzhouzhuan);

    }

    
   }
  }

 }

加载全部内容

相关教程
猜你喜欢
用户评论