银行家算法(操作系统实验报告).doc

上传人:b****2 文档编号:1465135 上传时间:2022-10-22 格式:DOC 页数:14 大小:296.50KB
下载 相关 举报
银行家算法(操作系统实验报告).doc_第1页
第1页 / 共14页
银行家算法(操作系统实验报告).doc_第2页
第2页 / 共14页
银行家算法(操作系统实验报告).doc_第3页
第3页 / 共14页
银行家算法(操作系统实验报告).doc_第4页
第4页 / 共14页
银行家算法(操作系统实验报告).doc_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

银行家算法(操作系统实验报告).doc

《银行家算法(操作系统实验报告).doc》由会员分享,可在线阅读,更多相关《银行家算法(操作系统实验报告).doc(14页珍藏版)》请在冰豆网上搜索。

银行家算法(操作系统实验报告).doc

实验报告

课程名称:

计算机操作系统实验名称:

银行家算法_

任课教师:

霍林专业:

计算机科学与技术

班级:

学号:

__

姓名:

蓝冠恒__完成日期:

2009年10月15日

一、实验目的:

加深对操作系统的进程管理与资源分配了解,深刻理解系统安全性检验算法。

二、主要实验内容及要求:

实验内容:

利用银行家算法检验系统的安全性。

实验要求:

1.输入系统进程数量n和资源类型数量m。

2.输入每类资源的数量。

3.输入每个进程每类资源的最大需求量和已获资源量。

4.检验系统的安全系。

三、实验结果与结论:

(经调试正确的源程序和程序的运行结果)

编程员:

蓝冠恒

程序源代码:

packagedisFace;

importorg.eclipse.swt.SWT;

importorg.eclipse.swt.custom.StackLayout;

importorg.eclipse.swt.events.SelectionAdapter;

importorg.eclipse.swt.events.SelectionEvent;

importorg.eclipse.swt.widgets.Button;

importorg.eclipse.swt.widgets.Composite;

importorg.eclipse.swt.widgets.Display;

importorg.eclipse.swt.widgets.Label;

importorg.eclipse.swt.widgets.Shell;

importorg.eclipse.swt.widgets.Text;

importorg.eclipse.ui.forms.widgets.FormToolkit;

importcom.swtdesigner.SWTResourceManager;

publicclassDisFace{

protectedShellshell;

privatefinalFormToolkitformToolkit=newFormToolkit(Display.getDefault());

privateCompositecomposite;

privateLabellabel;

privateLabellabel_1;

privateTextprocessN;

privateTextkindM;

privateButtonbutton1;

privateTextlistText;//输出文本框

privateCompositecomposite4;

privateLabellabel_3;

privateTextkindNumbers;//资源数量输入框

privateButtonbutton2;

privateTexttheKind1;

privateLabellabel_5;

privateLabellabel_6;

privateTextMaxText;//最大资源需求输入框

privateTextAllocationText;//已获资源输入框

privateButtonbutton3;

privateLabellabel_7;

privateTexttheProcess;

privateTexttheKind2;

privateLabellabel_11;

privateButtontest;

privateintN;//进程数量

privateintM;//资源类型数量

int[][]Max;//进程最大资源需求数组

int[][]Allocation;//进程已获资源数组

int[][]Need;//进程所需资源数组

int[]Available;//起初可用资源数组

int[]Work;//可提供资源数组

boolean[]Finish;//进程完成标识

inti=0;

intj=0;

intk=0;

privateCompositecomposite1;

StackLayoutstackLayout=newStackLayout();

StackLayoutstackLayout2=newStackLayout();

privateCompositecomposite3;

privateCompositecomposite2;

privateCompositecomposite0;

publicstaticvoidmain(String[]args){

try{

DisFacewindow=newDisFace();

window.open();

}catch(Exceptione){

e.printStackTrace();

}

}

publicvoidopen(){

Displaydisplay=Display.getDefault();

createContents();

shell.open();

shell.layout();

while(!

shell.isDisposed()){

if(!

display.readAndDispatch()){

display.sleep();

}

}

}

protectedvoidcreateContents(){

shell=newShell();

shell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));

shell.setText("银行家算法实现");

shell.setSize(733,565);

/*--------------------------------面板-------------*/

composite=newComposite(shell,SWT.BORDER);

composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_GREEN));

composite.setBounds(10,10,697,492);

composite.setData("name","composite");

formToolkit.adapt(composite);

formToolkit.paintBordersFor(composite);

composite0=newComposite(composite,SWT.NONE);

composite0.setBounds(0,1,210,156);

composite0.setData("name","composite0");

formToolkit.adapt(composite0);

formToolkit.paintBordersFor(composite0);

composite1=newComposite(composite,SWT.NONE);

composite1.setBackground(SWTResourceManager.getColor(SWT.COLOR_GREEN));

composite1.setBounds(210,1,224,156);

composite1.setData("name","composite1");

formToolkit.adapt(composite1);

formToolkit.paintBordersFor(composite1);

composite1.setLayout(stackLayout);

composite2=newComposite(composite1,SWT.BORDER);

composite2.setBackgroundMode(SWT.INHERIT_FORCE);

composite2.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));

composite2.setBackground(SWTResourceManager.getColor(0,255,0));

composite2.setData("name","composite2");

formToolkit.adapt(composite2);

formToolkit.paintBordersFor(composite2);

composite3=newComposite(composite,SWT.NONE);

composite3.setBounds(434,1,263,156);

composite3.setData("name","composite3");

formToolkit.adapt(composite3);

formToolkit.paintBordersFor(composite3);

composite3.setLayout(stackLayout2);

composite4=newComposite(composite3,SWT.BORDER);

composite4.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN));

composite4.setData("name","composite4");

formToolkit.adapt(composite4);

formToolkit.paintBordersFor(composite4);

/*--------------------------------标签----------------------*/

label_3=newLabel(composite2,SWT.HORIZONTAL);

label_3.setBounds(59,26,78,26);

label_3.setFont(SWTResourceManager.getFont("微软雅黑",12,SWT.NORMAL));

label_3.setData("name","label_3");

formToolkit.adapt(label_3,true,true);

label_3.setText("资源数量为");

label_5=newLabel(composite4,SWT.NONE);

label_5.setFont(SWTResource

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1