ImageVerifierCode 换一换
格式:DOCX , 页数:38 ,大小:261.27KB ,
资源ID:12679148      下载积分:6 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-12679148.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(操作系统课程 实验报告完整版.docx)为本站会员(b****8)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

操作系统课程 实验报告完整版.docx

1、操作系统课程 实验报告完整版中 南 大 学 操作系统实验报告姓 名:孙 福 星专 业 班 级:软件 1006班学 号: 完 成 日 期: 2011.11.22 进程调度与内存管理一、实验目的在采用多道程序设计的系统中,往往有若干个进程同时处于就绪状态。当就续进程个数大于处理器数时,就必须依照某种策略来决定哪些进程优先占用处理器。实验模拟实现处理机调度,以加深了解处理机调度的工作,并体会优先级和时间片轮转调度算法的具体实施方法。帮助了解在不同的存储管理方式下,应怎样实现主存空间的分配和回收。二、实验要求 1、可随机输入若干进程,并按优先权排序; 2、从就绪队首选进程运行:优先权-1/要求运行时间

2、-1 要求运行时间=0时,撤销该进程3、重新排序,进行下轮调度。4、可随时增加进程;5、规定道数,设置后备队列和挂起状态。若内存中进程少于规定道数,可自动从后备队列调度一作业进入。被挂起进程入挂起队列,设置解挂功能用于将指定挂起进程解挂入就绪队列。6、每次调度后,显示各进程状态。7、自行假设主存空间大小,预设操作系统所占大小并构造未分分区表; 表目内容:起址、长度、状态(未分/空表目) 8、结合以上实验,PCB增加为:PID,要求运行时间,优先权,状态,所需主存大小,主存起始位置, PCB指针 9、采用最先适应算法分配主存空间;10、进程完成后,回收主存,并与相邻空闲分区合并。11、采用图形界

3、面;三、实验内容选择一个调度算法,实现处理机调度。1、设计一个按优先权调度算法实现处理机调度的程序;2、设计按时间片轮转实现处理机调度的程序。3、主存储器空间的分配和回收。在可变分区管理方式下,采用最先适应算法实现主存空间的分配和回收。四、实验原理该模拟系统采用java语言实现,要实现的功能有新建进程、进程调度、挂起进程、解挂进程、删除进程,道数和时间片大小可以由用户自己调整,有两种调度策略:按优先权调度和按时间片轮转调度。每个进程可能有5种状态:新建(new)、就绪(ready)、运行(running)、阻塞(waiting)、挂起(suspend)。每个状态都有一个队列用来存放处于该状态的

4、进程,不同的调度策略采用不同的队列实现。当创建进程时,如果内存中的进程数还没达到规定道数,则将新建进程插入就绪队列,如果内存中进程数已经达到规定道数,则插到后备队列,后备队列中的进程的状态为new。CPU每次调度时都从就绪队列中取进程,在进程执行过程中如果下一个操作时IO操作,则将进程插入到waiting队列。在系统运行过程中可以执行进程挂起操作,但执行的挂起操作时系统自动暂停运行,在弹出窗口选择要挂起的进程后,将选中的进程从原来的队列中删除并插入到挂起队列。进行解挂操作时将选中的进程从挂起队列中删除并插入该进程原来所处的队列。按优先级调度: 当选择按优先权调度时,所有队列都采用优先队列,优先

5、队列采用一个有序链表实现,进程的优先权值越大代表优先级越高,优先队列中的进程按优先权从大到小排列,当新进程插入时根据该进程的优先权插入到队列中的合适位置,插入后保持队列按优先权从大到小排列,如果新进程与队列中某个进程优先权值相等,则该新进程插到那个进程后面,以遵循先来先服务的规则。当要从队列中取出进程时总是取队列中第一个进程,因为该进程的优先级最高。按时间片轮转调度:当选择按时间片轮转调度时,所有队列都采用先进先出队列,先进先出队列采用一个普通单向链表实现,当新进程插入时插入到队列的末尾,当要取进程时取队首进程,这样就实现了先进先出。内存管理该实验基于实验一完成,核心是内存的分配和回收,在实验

6、一的基础上增加内存管理部分,在新建进程的时候增加一个输入内存大小的输入框,在进程进入内存时要分配内存,在进程销毁时要回收内存,如果进入内存时内存不足,则将进程插入到后备队列等待下次调度。系统维护一个内存表,每个表项代表一个空间,每个空间保存了该空间的起始地址和空间大小以及空间使用状态。初始时只有一个空间,当CPU启动时要分配内存,内存分配采用最先适应算法。回收内存时如果有相邻空闲空间,则要进行空闲空间合并。 五、源代码及截图:1.divDTO:public class divDTO private int divBase; private int length; private int div

7、Flag; public divDTO(int divBase,int length,int divFlag) this.divBase = divBase; this.divFlag = divFlag; this.length = length; public divDTO() public void setDivBase(int base) this.divBase = base; public int getDivBase() return this.divBase; public void setLength(int length) this.length = length; pub

8、lic int getLength() return this.length; public void setDivFlag(int flag) this.divFlag = flag; public int getDivFalg() return this.divFlag; 2.PcbDTO:public class PcbDTO static final int Running = 1; static final int Ready = 2; static final int Waiting = 3; private String processName; private int runT

9、ime; private int prority; private int processState; private int base; private int limit; private int pcbFlag; public PcbDTO(String name, int time,int pro,int base,int limit) this.processName = name; this.runTime = time; this.prority = pro; this.processState = 0; this.limit = limit; this.base = base;

10、 public PcbDTO() this.pcbFlag = 0; public void setProcessName(String name) this.processName = name; public String getProcessName() return processName; public void setRunTime(int time) this.runTime = time; public int getRunTime() return this.runTime; public void setPrority(int prority) this.prority =

11、 prority; public int getPrority() return this.prority; public void setProcessState(int state) this.processState = state; public String getProcessState() String s = new String(); if(this.processState = 1) s = running; else if(this.processState = 2) s = ready; else if(this.processState = 3) s = waitin

12、g; return s; public int getBase() return this.base; public void setBase(int base) this.base = base; public void setLimit(int limit) this.limit = limit; public int getLimit() return this.limit; 3. import javax.swing.*;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.eve

13、nt.*;public class MainFrame private JList readyList; private JList waitingList; private JList jobList; private JButton susButton; private JButton relaxButton; private JButton startButton; private JButton newButton; private JLabel nameLabel; private JLabel prorityLabel; private JLabel timeLabel; priv

14、ate JLabel jobLabel; private JLabel readyLabel; private JLabel waitingLabel; private JLabel runningLabel; private JLabel spaceLabel; private JLabel divLabel; private JLabel allocLabel; private JTable readyTable; private JTable runningTable; private JTable divTable; private JTable allocTable; private

15、 JTextField nameText; private JTextField timeText; private JTextField spaceText; private JComboBox prorityCom; private JPanel newPanel; private JPanel waitingPanel; private JPanel readyPanel; Vector jobVectorName; Vector jobDtoVector; Vector waitingVectorName; Vector waitingDtoVector; PcbDTO readyDt

16、oArray; PcbDTO newDtoArray; divDTO divDtoArray; PcbDTO newSort; Object readydata; Object runningdata; Object divdata; Object allocdata; int first; int end; int point; PcbDTO a; public MainFrame() a = new PcbDTO(); first = 0; end = 0; point = 0; JFrame jf = new JFrame(进程调度-ws); Container c = jf.getCo

17、ntentPane(); c.setLayout(null); / c.setBackground(Color.pink); newPanel = new JPanel(); newPanel.setLayout(null); waitingPanel = new JPanel(); waitingPanel.setLayout(null); / waitingPanel.setBackground(Color.pink); readyPanel = new JPanel(); readyPanel.setLayout(null); susButton = new JButton(挂起); r

18、elaxButton = new JButton(释放); startButton = new JButton(开始); newButton = new JButton(新建进程); nameLabel = new JLabel(进程名); prorityLabel = new JLabel(优先级); timeLabel = new JLabel(运行时间); jobLabel = new JLabel(后备队列); readyLabel = new JLabel(就绪队列); waitingLabel = new JLabel(等待队列); runningLabel = new JLabe

19、l(运行进程); spaceLabel = new JLabel(需要空间); divLabel = new JLabel(未分分区表); allocLabel = new JLabel(内存分配表); nameText = new JTextField(); timeText = new JTextField(); spaceText = new JTextField(); prorityCom = new JComboBox(); prorityCom.setToolTipText(优先级); readyDtoArray = new PcbDTO6; newSort = new PcbDT

20、O6; for (int i = 0; i 6; i+) newSorti = new PcbDTO(); newDtoArray = new PcbDTO100; jobDtoVector = new Vector(); jobVectorName = new Vector(); waitingDtoVector = new Vector(); waitingVectorName = new Vector(); divDtoArray = new divDTO20; for (int i = 0; i 20; i+) divDtoArrayi = new divDTO(); divDtoAr

21、rayi.setDivFlag(0); divDtoArray0.setDivFlag(1); divDtoArray0.setDivBase(20); divDtoArray0.setLength(180); readydata = new Object64; runningdata = new Object23; divdata = new Object203; allocdata = new Object203; String col1 = 进程, 时间, 优先级, 状态 ; String col2 = 进程, 时间, 优先级 ; String col3 = 起址, 长度, 状态 ; S

22、tring col4 = 起址, 长度, 占用进程 ; readyTable = new JTable(readydata, col1); / readyTable.setEnabled(false); runningTable = new JTable(runningdata, col2); runningTable.setRowHeight(22); runningTable.setEnabled(false); allocTable = new JTable(allocdata, col4); allocTable.setEnabled(false); divTable = new JT

23、able(divdata, col3); divTable.setEnabled(false); divTable.setValueAt(String.valueOf(20), 0, 0); divTable.setValueAt(String.valueOf(180), 0, 1); divTable.setValueAt(String.valueOf(1), 0, 2); JScrollPane runningSP = new JScrollPane(); JScrollPane readySP2 = new JScrollPane(); JScrollPane divSP = new J

24、ScrollPane(); JScrollPane allocSP = new JScrollPane(); runningSP.getViewport().add(runningTable); readySP2.getViewport().add(readyTable); divSP.getViewport().add(divTable); allocSP.getViewport().add(allocTable); / int prorityArray = new int10; for (int i = 0; i 10; i+) prorityCom.addItem(i);/ prorit

25、yArrayi = i; jobList = new JList(); waitingList = new JList(); JScrollPane readySP = new JScrollPane(readyList); JScrollPane jobSP = new JScrollPane(jobList); JScrollPane waitingSP = new JScrollPane(waitingList); newPanel.setSize(450, 100); newPanel.setLocation(0, 0); nameLabel.setSize(80, 20); name

26、Label.setLocation(10, 5); nameText.setSize(100, 25); nameText.setLocation(10, 30); prorityLabel.setSize(80, 20); prorityLabel.setLocation(120, 5); prorityCom.setSize(100, 25); prorityCom.setLocation(120, 30); timeLabel.setSize(80, 20); timeLabel.setLocation(230, 5); timeText.setSize(100, 25); timeTe

27、xt.setLocation(230, 30); spaceLabel.setSize(80, 20); spaceLabel.setLocation(340, 5); spaceText.setSize(100, 25); spaceText.setLocation(340, 30); newButton.setSize(100, 20); newButton.setLocation(320, 70); waitingPanel.setSize(190, 410); waitingPanel.setLocation(0, 100); jobLabel.setSize(100, 20); jo

28、bLabel.setLocation(10, 2); jobSP.setSize(180, 105); jobSP.setLocation(10, 25); waitingLabel.setSize(100, 20); waitingLabel.setLocation(10, 129); waitingSP.setSize(180, 105); waitingSP.setLocation(10, 150); divLabel.setSize(100, 20); divLabel.setLocation(10, 253); divSP.setSize(180, 113); divSP.setLo

29、cation(10, 273); relaxButton.setSize(80, 20); relaxButton.setLocation(110, 388); readyPanel.setSize(260, 410); readyPanel.setLocation(190, 100); readyLabel.setSize(100, 22); readyLabel.setLocation(10, 2); allocLabel.setSize(100, 20); allocLabel.setLocation(10, 232); startButton.setSize(80, 20); startButton.setLocation(177, 388); susButton.setSize(80, 20); susButton.setLocation(

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2