收藏 分销(赏)

编写单通路IO系统中的设备分配程序实验报告.doc

上传人:人****来 文档编号:4579367 上传时间:2024-09-30 格式:DOC 页数:18 大小:252KB 下载积分:8 金币
下载 相关 举报
编写单通路IO系统中的设备分配程序实验报告.doc_第1页
第1页 / 共18页
编写单通路IO系统中的设备分配程序实验报告.doc_第2页
第2页 / 共18页


点击查看更多>>
资源描述
合肥学院 计算机科学与技术系 实验报告 2013 ~2014学年第1 学期 课程 操作系统原理 实验名称 编写单通路I/O系统中的 设备分配程序 学生姓名 张玉东 杨少帅 舒正昇 陈杰 孙元进 专业班级 11计本(3)班 指导教师 屠 菁 2000 年 12 月 一、实验目的 熟练掌握单通路I/O系统中的设备分配方法。 二、实验内容 本实验要求实现模拟单通路I/O系统中的设备分配程序,有如下要求: 1、设计系统设备表SDT、设备控制表DCT、控制器表COCT、通道表CHCT和逻辑设备表LUT。 2、提供给用户各表目的初态。 3、回答信息: 能够分配时,给出设备号、控制器号、通道号, 否则,给出无法分配的回答,插入相应的等待队列。 三、实验步骤 1、 任务分析 为单通路I/O系统设计系统设备表SDT、设备控制表DCT、控制器表COCT、通道表CHCT和逻辑设备表LUT五张表。用户可以查看各表目的内容,另外,程序为用户进程分配设备,并且输出分配结果,如果能够分配,则给出设备号、控制器号、通道号,否则,给出无法分配的回答,插入相应的等待队列。 2、概要设计 为实现本次实验任务要求,首先,定义SDT、DCT、COCT、CHCT、LUT五张表,调用AddCHCT、AddCOCT、AddDCT类初始化各表内容;其次,调用displaySDT、displayDCT、displayCOCT、displayCHCT、displayLUT方法实现对上述五张表的输出显示;最后,调用SimulationAdd类,为用户进程申请设备,如果分配成功,给出设备号、控制器号、通道号,否则,给出无法分配的原因,并将该进程插入相应的等待队列中。 本程序包含如下3个模块: (1) 主模块,由类Equipement组成。 (2) 初始化模块,由AddCHCT、AddCOCT、AddDCT类组成。 (3) 显示表目模块,由displaySDT、displayDCT、displayCOCT、displayCHCT、displayLUT方法组成。 (4) 分配设备模块,由SimulationAdd等类组成。 绘制流程图如下: 运行程序 ` 主类 运行进程申请设备 显示SDT、COCT、DCT、CHCT、LUT五张表 退出 判断设备是否存在 输出无法分配原因 判断控制器是否忙 输出无法分配原因 输入所需逻辑设备名称 判断通道是否忙 输出无法分配原因 给予分配,输出分配信息 Y N Y N Y N 流程图 3、详细设计和编码 通过以上的分析和初步设计,已经对本程序作了初步了解。下面将对本程序的各个模块作详细的讲解。 (1) 主类模块 调用各个子模块,完成特定的功能。 (2) 初始化模块 对各个表就行初始化,设置好各个表的状态,以及对各个步骤进行类调用来实现本实验的要求。 (3)显示表目模块 调用displaySDT、displayDCT、displayCOCT、displayCHCT、displayLUT方法,显示出SDT系统设备表、DCT设备控制表、COCT控制器控制表、CHCT通道表和LUT逻辑设备表五张表目,直接显示各表中的设备类型、设备名称和设备状态等信息。 (4) 分配设备模块 在此模块中,首先调用SimulationAdd类,要求用户选择所要申请的逻辑设备名称,然后根据逻辑设备名称查看LUT表中的该设备是否存在,若不存在,则直接退出分配,输出分配失败原因,若存在,则继续如下分析: a.分配设备。根据LUT表找到设备表,然后根据SDT表中指向DCT表该设备的指针,检索到DCT设备控制表中该物理设备,检查该设备的状态信息Busy。若忙,则将要求I/O的进程插入到该设备的等待队列中等待;若不忙,则继续步骤(b)。 b.分配控制器。根据设备控制表DCT中的控制器表指针,可找到与此设备相连的控制器表COCT,通过检查该表中的状态信息Busy。若忙,则将要求I/O的进程插入到等待该控制器的队列中等待;若不忙,则把该控制器分配给进程,继续步骤(c)。 c.分配通道。首先根据控制器表COCT中的通道表指针找到与此控制器相连的通道表CHCT,从中了解此通道的状态信息Busy。若为忙,则把该进程插入等待通道的队列CHL中;若通道空闲,则表明本次I/O请求所需之I/O设备和相应的控制器、通道都能得到,于是便可启动I/O设备开始数据传送。 调用equipementFunction方法来实现上述步骤。分配完成后,将相应的设备、控制器和通道的状态信息Busy置1。结束分配程序。 4、调试分析 本次程序设计的核心内容在于设备的分配过程,一次分配只有在设备、控制器和通道三者都分配成功时,这次分配才算成功。该程序的核心逻辑关系是先分配设备再分配控制器最后分配通道。当三者都空闲并安全时,才可分配,最终启动该I/O设备进行数据传送。 5、测试结果 数据库表: 主界面: 图1 图2 图3 初始化设备: 显示各表信息: 图4 进程分配信息 图5 四、实验总结 通过本次实验,充分的理解了单通道I/O设备分配程序,知道了设备表,控制器表,通道表以及其他表的数据结构,加深了对课本知识的理解,明白了设备分配的过程:先分配设备,接下来分配控制器,然后再分配通道,若成功就可以启动该I/O设备进行数据传送了。同时,通过和同学一起做这个实验,从中学习到了合作的经验,为以后的工作打下基础。经过编写程序,复习了JAVA语言程序。深刻体会团队分工合作的重要性。 五、附录 部分源程序: package cn.edu.hfuu.action; import java.awt.EventQueue; public class Equipement extends JFrame { private JPanel contentPane; public TextArea textArea; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Equipement frame = new Equipement(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public Equipement() { setTitle("\u6A21\u62DF\u5355\u901A\u8DEFI/O\u7CFB\u7EDF\u4E2D\u7684\u8BBE\u5907\u5206\u914D"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 561, 296); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu menu = new JMenu("\u6DFB\u52A0"); menuBar.add(menu); JMenuItem menuItem_3 = new JMenuItem("\u6DFB\u52A0\u901A\u9053"); menuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addCHCT(e); } }); menu.add(menuItem_3); JMenuItem menuItem_4 = new JMenuItem("\u6DFB\u52A0\u63A7\u5236\u5668"); menuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addCOCT(e); } }); menu.add(menuItem_4); JMenuItem menuItem_5 = new JMenuItem("\u6DFB\u52A0\u8BBE\u5907"); menuItem_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addDCT(e); } }); menu.add(menuItem_5); JMenu menu_1 = new JMenu("\u663E\u793A"); menuBar.add(menu_1); JMenuItem mntmsdt = new JMenuItem("\u7CFB\u7EDF\u8BBE\u5907\u8868(SDT)"); mntmsdt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displaySDT(e); } }); menu_1.add(mntmsdt); JMenuItem mntmdct = new JMenuItem("\u8BBE\u5907\u63A7\u5236\u8868(DCT)"); mntmdct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayDCT(e); } }); menu_1.add(mntmdct); JMenuItem mntmcoct = new JMenuItem("\u63A7\u5236\u5668\u63A7\u5236\u8868(COCT)"); mntmcoct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayCOCT(e); } }); menu_1.add(mntmcoct); JMenuItem mntmchct = new JMenuItem("\u901A\u9053\u63A7\u5236\u8868(CHCT)"); mntmchct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayCHCT(e); } }); menu_1.add(mntmchct); JMenuItem mntmlut = new JMenuItem("\u903B\u8F91\u8BBE\u5907\u8868(LUT)"); mntmlut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayLUT(e); } }); menu_1.add(mntmlut); JMenu menu_2 = new JMenu("\u8FD0\u884C"); menuBar.add(menu_2); JMenuItem menuItem_1 = new JMenuItem("\u6A21\u62DF\u8BBE\u5907\u5206\u914D"); menuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { simulationProcess(e); } }); menu_2.add(menuItem_1); JMenuItem menuItem_2 = new JMenuItem("\u5F00\u59CB\u8FD0\u884C\u8FDB\u7A0B"); menuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { equipementFunction(e); } }); menu_2.add(menuItem_2); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); textArea = new TextArea(); textArea.setBounds(10, 10, 521, 215); contentPane.add(textArea); } /** * 添加通道号 */ public void addCHCT(ActionEvent e){ AddCHCT addChct = new AddCHCT(); addChct.setVisible(true); } /** * 添加控制器 */ public void addCOCT(ActionEvent e){ AddCOCT addCoct = new AddCOCT(); addCoct.setVisible(true); } /** * 添加设备 */ public void addDCT(ActionEvent e){ AddDCT addDct = new AddDCT(); addDct.setVisible(true); } /** * 显示SDT * @param e */ public void displaySDT(ActionEvent e){ textArea.setText(null); textArea.setText("-----系统设备表------\n\n"); textArea.append("系统设备名称\n\n"); List sdtList = new ArrayList(); SDTDao sdtDao = new SDTDao(); sdtList = sdtDao.getSDTlist(); for(int i=0;i<sdtList.size();i++){ SDT sdt = (SDT)sdtList.get(i); textArea.append("设备"+sdt.getName()+"\n\n"); } textArea.append("--------------------\n"); } /** * 显示DCT */ public void displayDCT(ActionEvent e){ textArea.setText(null); textArea.setText("--------------------------------------设备控制表-------------------------------------\n\n"); textArea.append("设备类型\t设备名称\t设备状态\t控制器\t设备地址\t重复执行次数\n\n"); List dctList = new ArrayList(); DCTDao dctDao = new DCTDao(); dctList = dctDao.getDCTlist(); for(int i=0;i<dctList.size();i++){ DCT dct = (DCT)dctList.get(i); if(dct.getState()==0){ textArea.append(dct.getType()+"\t设备"+dct.getName()+"\t\t空闲\t\t "+dct.getCoct().getName()+"\t"+dct.getAddress()+"\t\t "+dct.getRepeat()+"\n\n"); } else{ textArea.append(dct.getType()+"\t设备"+dct.getName()+"\t\t忙\t\t "+dct.getCoct().getName()+"\t"+dct.getAddress()+"\t\t "+dct.getRepeat()+"\n\n"); } } textArea.append("------------------------------------------------------------------------------------\n"); } /** * 显示COCT */ public void displayCOCT(ActionEvent e){ textArea.setText(null); textArea.setText("------------控制器表-----------\n\n"); textArea.append("控制器名称\t状态\t通道表\n\n"); List coctList = new ArrayList(); COCTDao coctDao = new COCTDao(); coctList = coctDao.getCOCTlist(); for(int i=0;i<coctList.size();i++){ COCT coct = (COCT)coctList.get(i); if(coct.getState()==0){ textArea.append("控制器"+coct.getName()+"\t\t空闲\t "+coct.getChct().getName()+"\n\n"); } else { textArea.append("控制器"+coct.getName()+"\t\t忙\t "+coct.getChct().getName()+"\n\n"); } } textArea.append("------------------------------\n"); } /** * 显示CHCT */ public void displayCHCT(ActionEvent e){ textArea.setText(null); textArea.setText("--------通道表---------\n\n"); textArea.append("通道名称\t状态\n\n"); List chctList = new ArrayList(); CHCTDao coctDao = new CHCTDao(); chctList = coctDao.getCHCTlist(); for(int i=0;i<chctList.size();i++){ CHCT chct = (CHCT)chctList.get(i); if(chct.getState()==0){ textArea.append("通道"+chct.getName()+"\t\t空闲\n\n"); } else { textArea.append("通道"+chct.getName()+"\t\t忙\n\n"); } } textArea.append("-----------------------\n"); } /** * 显示LUT */ public void displayLUT(ActionEvent e){ textArea.setText(null); textArea.setText("--------逻辑设备表---------\n\n"); textArea.append("逻辑设备名称\t物理设备名称\n\n"); List lutList = new ArrayList(); LUTDao lutDao = new LUTDao(); lutList = lutDao.getLUTlist(); for(int i=0;i<lutList.size();i++){ LUT lut = (LUT)lutList.get(i); textArea.append(" "+lut.getName()+"\t\t 设备"+lut.getDct_name()+"\n\n"); } textArea.append("---------------------------\n"); } /** * 模拟过程输入信息 */ public void simulationProcess(ActionEvent e){ SimulationAdd simulation = new SimulationAdd(); simulation.setVisible(true); Equipement.this.setVisible(false); } /** * 运行进程 */ public void equipementFunction(ActionEvent e){ textArea.setText(null); DCTDao dctDao = new DCTDao(); COCTDao coctDao = new COCTDao(); CHCTDao chctDao = new CHCTDao(); Info info = new Info(); List processList = new ArrayList(); ProcessDao processDao = new ProcessDao(); processList = processDao.getProcesslist(); for(int i=0;i<processList.size();i++){ Process process = (Process)processList.get(i); info = processDao.getInfo2(process.getId()); if(process.getState()==4){ dctDao.updateDCT(0, info.getDctName()); coctDao.updateCOCT(0, info.getCoctName()); chctDao.updateCHCT(0, info.getChctName()); processDao.updateProcess(0, process.getName()); JOptionPane.showMessageDialog(this, process.getName()+"进程运行完成!!","友情提示", JOptionPane.INFORMATION_MESSAGE); } } } } package cn.edu.hfuu.action; import java.awt.Choice; public class SimulationAdd extends JFrame { private JPanel contentPane; private JTextField textField; private JTextField textField_1; private Choice choice; public Info info; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { SimulationAdd frame = new SimulationAdd(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public SimulationAdd() { setTitle("\u8F93\u5165\u6A21\u62DF\u4FE1\u606F"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 246, 169); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel label = new JLabel("\u8FDB\u7A0B\u540D\uFF1A"); label.setFont(new Font("宋体", Font.PLAIN, 14)); label.setBounds(45, 10, 56, 15); contentPane.add(label); textField = new JTextField(); textField.setBounds(111, 7, 88, 21); contentPane.add(textField); textField.setColumns(10); JLabel label_1 = new JLabel("\u903B\u8F91\u8BBE\u5907\u540D:"); label_1.setFont(new Font("宋体", Font.PLAIN, 14)); label_1.setBounds(20, 47, 88, 15); contentPane.add(label_1); choice = new Choice(); List lutList = new ArrayList(); LUTDao lutDao = new LUTDao(); lutList = lutDao.getLUTlist(); for(int i=0;i<lutList.size();i++){ LUT lut = (LUT)lutList.get(i); choice.add(lut.getName()); } choice.setBounds(111, 44, 88, 21); contentPane.add(choice); JButton button = new JButton("\u786E\u5B9A"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addSimulation(e); } }); button.setBounds(37, 89, 64, 23); contentPane.add(button); JButton button_1 = new JButton("\u53D6\u6D88"); button_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SimulationAdd.this.setVisible(false); Equipement equi = new Equipement(); equi.setVisible(true); } }); button_1.setBounds(135, 89, 64, 23); contentPane.add(button_1); } /** * 模拟进程信息 */ public void addSimulation(ActionEvent e){ int state=0; Process process = new Process(); process.setName(textField.getText()); process.setState(state); ProcessDao processDao = new ProcessDao(); processDao.addProcess(process); Process process1 = processDao.getProcess(textField.getText()); SDTDao sdtDao = new SDTDao(); sdtDao.updateSDT(process1.getId(), choice.getSelectedItem()); info = processDao.getInfo(choice.getSelectedItem()); Equipement equi = new Equipement(); equi.setVisible(true); equi.textArea.setText(null); DCTDao dctDao = new DCTDao(); COCTDao coctDao = new COCTDao(); CHCTDao chctDao = new CHCTDao(); if(info.getDctState()==1){ processDao.updateProcess(1, textField.getText()); equi.textArea.append("设备"+info.getDctName()+"忙,进程插入到设备控制表等待队列\n"); } else{ dctDao.updateDCT(1, info.getDctName()); processDao.updateProcess(2, textField.getText()); if(info.getCoctState()==1){ equi.textArea.append("控制器"+info.getCoctName()+"忙,进程插入到控制器控制表等待队列\n"); } else{ dctDao.updateDCT(1, info.getDctName()); coctDao.updateCOCT(1, info.getCoctName()); processDao.updateProcess(3, textField.getText()); if(info.getChctState()==1){ equi.textArea.append("通道"+info.getCoctName()+"忙,进程插入到通道控制表等待队列\n"); }else{ dctDao.updateDCT(1, info.getDctName()); coctDao.updateCOCT(1, info.getCoctName()); chctDao.updateCHCT(1, info.getChctName()); processDao.updateProcess(4, textField.getText()); equi.textArea.append("设备"+info.getDctName()+"空闲,分配成功\n"); equi.textArea.append("控制器"+info.getCoctName()+"空闲,分配成功\n"); equi.textArea.append("通道"+info.getCoctName()+"空闲,可以允许该进程\n"); } } } SimulationAdd.this.se
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服