⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 操作系统实验的进程管理源代码
💻 JAVA
字号:
package algo;
public  class Test  implements Resource {
	static process[] pro=new process[4];
	static Table table;
	     public static void main(String args[]){       	 
         pro[0]=new process(new int[]{3,1,2},new int[]{1,0,0});pro[0].name="one  ";
      	 pro[1]=new process(new int[]{2,3,1},new int[]{1,2,1});pro[1].name="two  ";
      	 pro[2]=new process(new int[]{1,2,3},new int[]{1,1,0});pro[2].name="three";
      	 pro[3]=new process(new int[]{2,1,0},new int[]{1,0,0});pro[3].name="four ";  	 
      	 table=new Table(pro);
      	 warm();//作者声明
	     tot();  //资源情况   
	     ava();     //资源可用情况	 
      	 headline(); //表头
      	 pro();      //进程情况   	                  
      	 System.out.println("现在系统处于"+(table.securityExam()?  "安全状态":"不安全状态")); 
      	 que();      //进程执行顺序
      	 ava();
      /*	 */
      }
      public static void headline(){
      	 System.out.println("===========================================================================");
      	 System.out.println("process\t\tmax\t\t\t allocation\t \t need");
      	 System.out.print("\t<"+resources[0]+"|"+resources[1]+"|"+resources[2]+">  <");
      	 System.out.print(resources[0]+"|"+resources[1]+"| "+resources[2]+">  <");
      	 System.out.println(resources[0]+"|"+resources[1]+"|  "+resources[2]+">");
      }
      public static void pro(){
      	  for(int i=0;i<pro.length;i++){
           System.out.println("["+i+"]:"
           +pro[i].name+" "+pro[i].Max[0]+"\t"+pro[i].Max[1]+"\t"+pro[i].Max[2]
      	   +"\t"+pro[i].Allocation[0]+"\t"+pro[i].Allocation[1]+"\t"+pro[i].Allocation[2]
      	   +"\t"+pro[i].Need[0]+"\t"+pro[i].Need[1]+"\t "+pro[i].Need[2]);
      	 }
      	 System.out.println("===========================================================================");
      }
      public static void chart(){
      	headline();
      	pro();
      }
      public static void ava(){
      	  System.out.print("资源Avaliable:");
      	 for(int i=0;i<table.Avaliable.length;i++){
      	 System.out.print(resources[i]+":"+table.Avaliable[i]+"\t");
      	 }
      	 System.out.println();
      }
      public static void tot(){
      	 System.out.println("资源列表:\t名称,总数");
      	 for(int i=0;i<Total.length;i++){
      	 System.out.print(resources[i]+":"+Total[i]+"\t");
      	 }
      	 System.out.println("");
      }
      public static void que(){
      	 System.out.println("进程执行顺序为:");
      	 for(int i=table.pro.length-1;i>=0;i--){
      	 System.out.print(table.pro[i].name+"\t");
      	 }
      	 System.out.println("");
      }
     public static void warm(){
     	System.out.println("\t\t\t银行家算法");
     	System.out.println("\t\t\t----作者:刘联东");
     	System.out.println("----------------------------------------------------------------");
     } 
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -