自己写的操作系统模拟实验

上传人:笛音 文档编号:25743806 上传时间:2017-12-17 格式:DOCX 页数:19 大小:35.15KB
返回 下载 相关 举报
自己写的操作系统模拟实验_第1页
第1页 / 共19页
自己写的操作系统模拟实验_第2页
第2页 / 共19页
自己写的操作系统模拟实验_第3页
第3页 / 共19页
自己写的操作系统模拟实验_第4页
第4页 / 共19页
自己写的操作系统模拟实验_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《自己写的操作系统模拟实验》由会员分享,可在线阅读,更多相关《自己写的操作系统模拟实验(19页珍藏版)》请在金锄头文库上搜索。

1、操作系统实验本系统由计算机 1002 班第四组完成,成员:雷鹏(组长),孔振明,郝广苏,黄林思,董英杰一、 实验名称进程调度实验二、 实验内容 选择一个调度算法,实现处理机调度; 处理机调度过程中可以对进程进行阻塞 标识数唯一,因此可以添加相同进程名的进程。三、 实验目的学习进程管理的设计与实现,学习和运用操作系统原理,设计一个操作系统的模拟系统,通过该系统的设计调试可增加对操作系统实现的感知性。同时可发挥团队协作精神和个人创造能力。四、 实验题目设计一个操作系统调度程序,其中一共采用了两种调度算法(1) 按照优先权优先调度算法实现处理机调度的程序(2) 按照先来先服务算法实现处理调度总结:雷

2、鹏(界面设计以及 CPU 执行模块,两种算法的设计)孔振明(就绪队列以及创建进程监听器,操作系统设计以及使用说明书)郝广苏(阻塞运行和运行)董英杰(阻塞队列和阻塞按钮监听器)黄林思(唤醒和撤销)五、 实验过程设计思路实验设计思想: 本实验采用 java 语言编程,并实现 GUI 界面显示 为体现 java 语言面向对象程序设计的特点,实验设计为 PCB 类封装进程控制块所非配的内存各自的属性和方法;PCBecords 封装数组方法;用 ProcessScheduling 实现 GUI 界面显示 PCB 类中,定义进程名、标识数、优先数和运行时间这 4 个属性,并定义各属性的 get 和 set

3、 方法,定义 equals 方法用语对比类的属性,定义 toString 方法得到类属性的字符串PCB 进程名(pname) 标识数(PID) 优先数(Priority) 运行时间(RequriedTime) getpname() getPID() getRequiredTime() getPriority() getStatus() toString() run()PCBrecords getPCBItems() PCBrecords() addItem(PCB PcbItem) removeItem(PCB PCbItem) getItem(PCB processPCB) getItemb

4、yid (int pid) getItem(String pname) getNumberOfItems() getItemsProperties()ProcessScheduling阻塞队列就绪队列CPU 执行 PCBrecords 封装 PCB 数组的添加元素 addItem 和删除元素 removeItem方法六、 实验代码类 PCBpublic class PCB private String pname;private int PID;private int RequiredTime;private int Priority;private String Status;/ priva

5、te String PCBPointer;public PCB(String pname, int initpID, int initpriority, int initRTime)this.pname=pname;this.PID = initpID;this.RequiredTime = initRTime;this.Priority = initpriority;this.Status = 就绪;public String getpname()if(this.pname=null)return ;elsereturn this.pname;public int getPID() retu

6、rn this.PID;public int getRequiredTime() return this.RequiredTime;public int getPriority() return this.Priority;public String getStatus() if(this.Status = null)return ;elsereturn this.Status;public boolean equals(PCB pcb) if(pcb.getPID() = this.getPID() return true;else return false;public String to

7、String() return 进程名_+this.getpname()+_标识数_+this.getPID() + _优先数_+this.getPriority()+ _运行时间 _ + this.getRequiredTime() + ;n;public void run() this.RequiredTime = this.RequiredTime-1;类 PCBrecordsimport java.util.ArrayList;import java.util.Iterator;/向客户程序提供遍历各种类型的集合的统一接口public class PCBrecords implemen

8、ts Iterable private ArrayList PCBItems;public ArrayList getPCBItems() return this.PCBItems;public PCBrecords() this.PCBItems = new ArrayList(); public void addItem(PCB PcbItem) this.PCBItems.add(PcbItem);public void removeItem(PCB PCbItem) this.PCBItems.remove(PCbItem);public PCB getItem(PCB process

9、PCB) for (PCB pCbItem : this.PCBItems) if (pCbItem.equals(processPCB) return pCbItem;return null;public PCB getItembyid (int pid) for (PCB pcBItem : this.PCBItems) if (pcBItem.getPID()=pid) return pcBItem;return null;public PCB getItem(String pname) for (PCB pcBItem : this.PCBItems) if (pcBItem.getp

10、name().equals(pname) return pcBItem;return null;public int getNumberOfItems() return this.PCBItems.size();public String getItemsProperties() String itemsProperties = new StringgetNumberOfItems();int i = 0;for(Iterator iterator1 = PCBItems.iterator(); iterator1.hasNext();) PCB stu_Item = (PCB)iterato

11、r1.next();itemsPropertiesi+ = stu_Item.toString();return itemsProperties;public Iterator iterator() return this.PCBItems.iterator();主类 ProcessSchedulingpackage src;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.border.*;import java.io.*;i

12、mport java.util.*;public class ProcessScheduling extends JFramestatic private int Ready_CELL_SIZE = 200, Ready_LIST_ROWS = 6;static private int Suspend_CELL_SIZE = 250, Suspend_LIST_ROWS = 10;private int 调度方式标志 ,中断标志位=0, 运行队列为空标志位=1;private JPanel 进程创建,阻塞队列,就绪队列,CUP 执行,控制台; private JButton 创建进程,阻塞,撤

13、销,唤醒,运行, 中断;private JTextField 进程名 ,标识数 ,优先数,运行时间;private JTextArea runinglist;private JRadioButton 优先数优先,先来先服务;private JLabel 进程名标签,标识数标签, 优先数标签, 运行时间标签;private JList 就绪列表, 阻塞列表;PCBrecords readyPCB, suspendedPCB;public ProcessScheduling(String title)super(title);initFrame();public void initFrame()

14、创建进程=new JButton(创建进程);阻塞=new JButton(阻塞);撤销=new JButton(撤销);唤醒=new JButton(唤醒);运行=new JButton(运行);中断=new JButton(阻塞运行);进程名=new JTextField();标识数=new JTextField();优先数=new JTextField();runinglist=new JTextArea();readyPCB = new PCBrecords();suspendedPCB = new PCBrecords();运行时间=new JTextField();优先数优先=ne

15、w JRadioButton(优先数优先 );先来先服务=new JRadioButton(先来先服务 ,true); 就绪列表= new JList();就绪列表.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);就绪列表.setVisibleRowCount(Ready_LIST_ROWS);就绪列表.setFixedCellWidth(Ready_CELL_SIZE);阻塞列表=new JList();阻塞列表.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);阻塞列表.setVisibleRowCount(Suspend_LIST_ROWS);阻塞列表.setFixedCellWidth(Suspend_CELL_SIZE);运行.addActionListener(new StartSystemListener();撤销.addActionListener(new RemoveListener();创建进程.addActionListener(new AddToReadyListener();阻塞.addActionListener(new SuspendListener();唤醒.addActionListener(ne

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 其它文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号