计算机操作系统实验讲义 联系客服

发布时间 : 星期五 文章计算机操作系统实验讲义更新完毕开始阅读6ded4ea8102de2bd97058819

} }

void main(void){ Read_Initiate();

cout<

for(int i=0;i

cout<

DWORD m_delay=3000; Sleep(m_delay);

cout<<\读入成功\

Allocated_list();

for(i=0;i

Sleep(m_delay);

cout<<\读入成功\

Set_Need();

for(i=0;i

Sleep(m_delay);

cout<<\设置成功\

Read_Request();

cout<<'\\n'<<\第\个进程请求第\类资源\个\cout<<'\\n'<<\读入成功\RUN(); }

注:数组Array[I]表示第I+1个实际意义量需要创建三个txt文本。 1.Initiate.txt文本

3 3 3 2 //共有3类资源,Available[0]=3; Available[1]=3; Available[2]=2 5 //当前系统中有个进程 7 5 3 // Max[0][0]=7 3 2 2 //Max[1][1]=3 9 0 2 2 2 2 4 3 3

2.Allocated_list.txt文本

0 1 0 //Allocation[0][1]=1 2 0 0 3 0 2 2 1 1 0 0 2

3.Request_list.txt文本

Java程序2 import java.util.*; public class Bank {

public static void main(String[] args) {

int process;//定义进程数量 int resource=3;//定义资源种类是3 int[] available;//可利用的资源

int[][] max,allocation,need;//分别是最大的需求数、已分配的资源、需求资源

Scanner scanner=new Scanner(System.in); System.out.print(\请输入进程数>>\process=scanner.nextInt();

System.out.print(\请输入可利用资源向量(已定义3个资源种类)>>\

available=new int[resource]; for (int i = 0; i < resource; i++) { }

System.out.println(\请输入分配矩阵\allocation=new int[process][resource];

available[i]=scanner.nextInt();

for (int i = 0; i

System.out.print(\请输入进程\已分配的资源数>>\

}

System.out.println(\请输入最大需求矩阵\max=new int[process][resource]; for (int i = 0; i

for (int j = 0; j < resource; j++) { }

allocation[i][j]=scanner.nextInt();

System.out.print(\请输入进程\最大需求的资源数>>\

}

need=new int[process][resource]; for (int i = 0; i < process; i++) { }

System.out.println(); /*

* 打印资源分配表 * */

System.out.println(\时刻的资源分配表\

for (int j = 0; j < resource; j++) { }

need[i][j]=max[i][j]-allocation[i][j]; for (int j = 0; j < resource; j++) { }

max[i][j]=scanner.nextInt();

System.out.println(\进程 max\\t\\tallocation\\t need\\t\\tavailable\

System.out.print(\ \

for (int i = 0; i

System.out.print(\ \

for (int i = 0; i

}

System.out.print(\ \

for (int i = 0; i

System.out.print(\ \

for (int i = 0; i

System.out.println();

for (int i = 1; i < process; i++) { System.out.print(\ \ for (int j = 0; j < resource; j++) { System.out.print(max[i][j]+\ \ }

System.out.print(\ \

for (int j = 0; j < resource; j++) { System.out.print(allocation[i][j]+\ }

System.out.print(\ \

for (int j = 0; j < resource; j++) { System.out.print(need[i][j]+\ \ }

\