﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Brian Warehouse-随笔分类-OS</title><link>http://www.cppblog.com/Icho/category/14620.html</link><description>Some birds aren`t meant to be caged, their feathers are just too bright... ...</description><language>zh-cn</language><lastBuildDate>Tue, 17 Aug 2010 07:16:58 GMT</lastBuildDate><pubDate>Tue, 17 Aug 2010 07:16:58 GMT</pubDate><ttl>60</ttl><item><title>实验三代码 文件管理</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123691.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 05:04:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123691.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123691.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123691.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123691.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123691.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: /*Title:&nbsp;文件管理Author:&nbsp;BrianDate:&nbsp;2010/06/17*/#include&nbsp;&lt;iostream&gt;#include&nbsp;&lt;fstream&gt;#include&nbsp;&lt;cstdlib&gt;#include&nbsp;&lt;cstring&gt;using&nbsp;namespace&nbs...&nbsp;&nbsp;<a href='http://www.cppblog.com/Icho/archive/2010/08/17/123691.html'>阅读全文</a><img src ="http://www.cppblog.com/Icho/aggbug/123691.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 13:04 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123691.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实验三 文件管理(指导书)</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123690.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 05:03:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123690.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123690.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123690.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123690.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123690.html</trackback:ping><description><![CDATA[<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一、实验内容</span><span lang=EN-US></span></strong></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">利用高级语言，</span><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 宋体">设计一个采用二级或二级以上的多级文件目录管理系统，实现对文件的基本操作，如：文件的建立、打开、关闭、复制、撤销、检索等。<span lang=EN-US></span></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">二、实验目的</span><span lang=EN-US></span></strong></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用高级语言编写和调试一个简单的文件系统，模拟文件管理的工作过程。从而对各种文件操作命令的实质内容和执行过程有比较深入的了解。</span><span lang=EN-US><font face="Times New Roman"> </font></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要求设计一个</span><span lang=EN-US><font face="Times New Roman"> n</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个用户的文件系统，每次用户可保存</span><span lang=EN-US><font face="Times New Roman">m</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个文件，用户在一次运行中只能打开一个文件，对</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件必须设置保护措施，且至少有</span><span lang=EN-US><font face="Times New Roman">Create</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">delete</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">open</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">close</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">read</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">write</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等命令。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">三</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体">、实验环境</span></strong><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face="Times New Roman">1</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">．</span><span lang=EN-US><font face="Times New Roman">PC</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">微机。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face="Times New Roman">2</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">．</span><span lang=EN-US><font face="Times New Roman">Windows </font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作系统。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face="Times New Roman">3</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">．</span><span lang=EN-US><font face="Times New Roman">C/C++/VB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发集成环境。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">四、实验题目</span><span lang=EN-US></span></strong></p>
<p style="TEXT-INDENT: 21.25pt; MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设计一个</span><span lang=EN-US><font face="Times New Roman">10</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个用户的文件系统，每次用户可保存</span><span lang=EN-US><font face="Times New Roman">10</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个文件，一次运行用户可以打开</span><span lang=EN-US><font face="Times New Roman">5</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个文件。</span><span lang=EN-US><font face="Times New Roman">&nbsp;</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序采用二级文件目录（即设置主目录</span><span lang=EN-US><font face="Times New Roman">[MFD]</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）和用户文件目录（</span><span lang=EN-US><font face="Times New Roman">UED</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）。另外，为打开文件设置了运行文件目录（</span><span lang=EN-US><font face="Times New Roman">AFD</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）。</span><span lang=EN-US><font face="Times New Roman">&nbsp;</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为了便于实现，对文件的读写作了简化，在执行读写命令时，只需改读写指针，并不进行实际的读写操作。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: 31.85pt; MARGIN: 0cm 0cm 0pt; mso-char-indent-count: 3.02"><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">算法设计思想：</span><span lang=EN-US></span></strong></p>
<p style="TEXT-INDENT: -36pt; MARGIN: 0cm 0cm 0pt 57.25pt; mso-list: l0 level1 lfo1; tab-stops: list 57.25pt"><span style="mso-bidi-font-family: 宋体" lang=EN-US><span style="mso-list: Ignore"><font face="Times New Roman">（1）<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">因系统小，文件目录的检索使用了简单的线性搜索。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: -36pt; MARGIN: 0cm 0cm 0pt 57.25pt; mso-list: l0 level1 lfo1; tab-stops: list 57.25pt"><span style="mso-bidi-font-family: 宋体" lang=EN-US><span style="mso-list: Ignore"><font face="Times New Roman">（2）<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件保护简单使用了三位保护码：允许读写执行、对应位为</span><span lang=EN-US><font face="Times New Roman"> 1</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，对应位为</span><span lang=EN-US><font face="Times New Roman">0</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，则表示不允许读写、执行。</span><span lang=EN-US></span></p>
<p style="TEXT-INDENT: -36pt; MARGIN: 0cm 0cm 0pt 57.25pt; mso-list: l0 level1 lfo1; tab-stops: list 57.25pt"><span style="mso-bidi-font-family: 宋体" lang=EN-US><span style="mso-list: Ignore"><font face="Times New Roman">（3）<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序中使用的主要设计结构如下：</span><span lang=EN-US></span></p>
<p style="MARGIN: 0cm 0cm 0pt 21.25pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主文件目录和用户文件目录（</span><span lang=EN-US><font face="Times New Roman"> MFD</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang=EN-US><font face="Times New Roman">UFD</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），</span><span lang=EN-US><font face="Times New Roman">&nbsp; </font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">打开文件目录（</span><span lang=EN-US><font face="Times New Roman"> AFD</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）（即运行文件目录）</span><span lang=EN-US></span></p>
<table style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-yfti-tbllook: 480" border=1 cellSpacing=0 cellPadding=0>
    <tbody>
        <tr style="HEIGHT: 4.55pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>M D F</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>U F D</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>A F D</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
        </tr>
        <tr style="HEIGHT: 4.55pt; mso-yfti-irow: 1">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">用户名</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">文件名</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">打开文件名</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
        </tr>
        <tr style="HEIGHT: 4.55pt; mso-yfti-irow: 2">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">文件目录指针</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">保护码</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">打开保护码</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
        </tr>
        <tr style="HEIGHT: 4.55pt; mso-yfti-irow: 3">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">用户名</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">文件长度</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">读写指针</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
        </tr>
        <tr style="HEIGHT: 4.55pt; mso-yfti-irow: 4">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">文件目录指针</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">文件名</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 4.55pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt" align=center><span style="mso-bidi-font-size: 10.5pt" lang=EN-US><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
        </tr>
        <tr style="HEIGHT: 29.45pt; mso-yfti-irow: 5; mso-yfti-lastrow: yes">
            <td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.05pt; PADDING-RIGHT: 5.4pt; HEIGHT: 29.45pt; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="MARGIN: 0cm 0cm 0pt"><span style="mso-bidi-font-size: 10.5pt" lang=EN-US><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 29.45pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-line-height-alt: 7.0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>&#183;</span></p>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-line-height-alt: 7.0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>&#183;</span></p>
            <p style="TEXT-ALIGN: center; MARGIN: 0cm 0cm 0pt; mso-line-height-alt: 7.0pt" align=center><span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" lang=EN-US>&#183;</span><span style="mso-bidi-font-size: 10.5pt" lang=EN-US></span></p>
            </td>
            <td style="BORDER-BOTTOM: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; PADDING-LEFT: 5.4pt; WIDTH: 131.1pt; PADDING-RIGHT: 5.4pt; HEIGHT: 29.45pt; BORDER-LEFT-COLOR: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=175>
            <p style="MARGIN: 0cm 0cm 0pt"><span style="mso-bidi-font-size: 10.5pt" lang=EN-US><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/Icho/aggbug/123690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 13:03 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123690.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实验二代码 首次适应法 位示图法</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123689.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 05:02:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123689.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123689.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123689.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123689.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123689.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: /*Title:&nbsp;首次适应算法Author:&nbsp;BrianDate:&nbsp;2010/05/31*/#include&nbsp;&lt;iostream&gt;#include&nbsp;&lt;cstdlib&gt;&nbsp;//&nbsp;system()using&nbsp;namespace&nbsp;std;typedef&nbsp;struct&nbsp;SNo...&nbsp;&nbsp;<a href='http://www.cppblog.com/Icho/archive/2010/08/17/123689.html'>阅读全文</a><img src ="http://www.cppblog.com/Icho/aggbug/123689.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 13:02 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123689.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实验二 内存储器空间的管理(指导书)</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123688.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 05:00:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123688.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123688.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123688.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123688.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123688.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一、实验内容利用高级语言，实现存储分配算法，开发一个存储管理的模拟程序,对内存空间的管理和分配。内存空间的管理可采用固定分区管理方式，可变分区管理方式,页式存储管理，段式存储管理等方案。二、实验目的一个好的计算机系统不仅要有一个足够容量的、存取速度高的、稳定可靠的主存储器，而且要能合理地分配和使用这些存储空间。当用户提出申请存储器空间时，存储管理必须根据申请者的要求，按一定的策略分析主...&nbsp;&nbsp;<a href='http://www.cppblog.com/Icho/archive/2010/08/17/123688.html'>阅读全文</a><img src ="http://www.cppblog.com/Icho/aggbug/123688.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 13:00 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123688.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实验一代码 时间片轮转法 高响应比优先</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123687.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 04:59:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123687.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123687.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123687.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123687.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123687.html</trackback:ping><description><![CDATA[<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 12pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br>Title:&nbsp;时间片轮转法<br>Author:&nbsp;Brian<br>Date:&nbsp;2010/04/09<br></span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">cstdlib</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;std;<br><br>typedef&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;PNode&nbsp;{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;PCB</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;PNode&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">next;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">指向下一个节点的指针</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;name[</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">];&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;进程名</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;All_Time;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;总运行时间</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;Runed_Time;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;已运行时间</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;state;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;进程状态&nbsp;Ready&nbsp;/&nbsp;End</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;Proc;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;指向该PCB的指针</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;全局变量，用于用户自己确定进程个数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;InitPCB(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)&nbsp;{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">初始化就绪队列</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">输入总进程个数:&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">进程总个数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;Num</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ProcNum;<br>&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(Proc)malloc(</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(PNode));&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H;<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">总进程个数默认为&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">ProcNum</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;个,请输入相应信息\n\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(Num</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(Proc)malloc(</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(PNode));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">进程名&nbsp;总运行时间&nbsp;已运行时间&nbsp;:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">R</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;构造循环队列</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;DispInfo(Proc&nbsp;H)&nbsp;{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">输出运行中信息</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">进程名:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t总运行时间:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t已运行时间:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t状态:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;整个进程链条始终完整，只是状态位有差异</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;SJP_Simulator(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)&nbsp;{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;时间片轮转法模拟器</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-------------------START--------------------\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;flag</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;记录剩余进程数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;round</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;记录轮转数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time&nbsp;</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;round</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Round&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">round</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">--正在运行&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;进程</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DispInfo(H);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;进程已运行结束,进程被删除!\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(flag&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Runed_Time)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;这一步非常重要，跳过先前已结束的进程</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">--------------------END---------------------\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;main()&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;H;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitPCB(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;数据初始化</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;DispInfo(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;初始化成功后的进程状态</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;SJP_Simulator(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;模拟时间片轮转法</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>}<br></span></div>
<p>&nbsp;</p>
<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 12pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br>Title:&nbsp;高响应比优先算法<br>Author:&nbsp;Brian<br>Date:&nbsp;2010/04/11<br></span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">cstdlib</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">cstring</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;std;<br><br>typedef&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;PNode&nbsp;{&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">PCB</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;PNode&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">next;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">指向下一个节点的指针</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;name[</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">进程名</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;All_Time;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">要求运行时间</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;Wait_Time;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">等待时间</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">&nbsp;Res_Ratio;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">响应比&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;state;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">状态&nbsp;Ready/End&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">}</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;Proc;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">指向该PCB的指针</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;全局变量，用于用户自己确定进程个数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;ComputeRes(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">计算响应比</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">{<br>&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">R</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">)(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0.0</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;InitProc(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">输入总进程个数:&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">进程总个数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;Num</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ProcNum;<br>&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(Proc)malloc(</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(PNode));&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H;<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">总进程个数默认为&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">ProcNum</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;个,请输入相应信息\n\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(Num</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(Proc)malloc(</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(PNode));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">进程名&nbsp;总运行时间&nbsp;等待时间&nbsp;:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">R</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">)(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;DispInfo(Proc&nbsp;H)&nbsp;{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">输出运行中信息</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">进程名:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t总运行时间:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t等待时间:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t响应比:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\t状态:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;RelocateMax(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;进程排序&nbsp;(逆序算法)&nbsp;,&nbsp;首节点是响应比最高节点</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">NULL&nbsp;</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;只剩一个节点或没有节点时无需排序</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next,q,r;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">r;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(q</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;q</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">q</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">q</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">r;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(p)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">q;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;HRN_Simulator(Proc&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">H)&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">高响应比算法模拟器</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">{<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-------------------START--------------------\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;flag</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ProcNum;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;记录剩余进程数</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(flag)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Wait_Time</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Res_Ratio</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1.0</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">All_Time&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">state&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ComputeRes(H);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DispInfo(H);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;H</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">next;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">将首节点删除&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">name</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;进程已运行结束\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DispInfo(H);ComputeRes(H);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RelocateMax(H);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">--------------------END---------------------\n\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>}<br><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;main()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;Proc&nbsp;H;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitProc(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;数据初始化</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;DispInfo(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;初始化成功后的进程状态</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;HRN_Simulator(H);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;模拟高响应比优先算法</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>}<br></span></div>
<img src ="http://www.cppblog.com/Icho/aggbug/123687.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 12:59 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123687.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实验一 进程调度(指导书)</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123686.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 04:57:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123686.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123686.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123686.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123686.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123686.html</trackback:ping><description><![CDATA[<p><strong><span>一、实验内容</span></strong></p>
<p><span>利用高级语言模拟进程的时间片轮转调度算法，响应比高者优先调度算法。</span></p>
<p><strong><span>二、实验目的</span></strong></p>
<p><span>在采用多道程序设计的系统中，往往有若干个进程同时处于就绪状态。当就绪进程个数大于处理器数时，就必须依照某种策略来决定哪些进程优先占用处理器。本实验模拟在单处理器情况下的处理器调度，帮助学生加深了解处理器调度的工作。</span></p>
<p><strong><span>三</span></strong><strong><span>、实验环境</span></strong></p>
<p><span><font face="Times New Roman">1</font></span><span>．</span><span><font face="Times New Roman">PC</font></span><span>微机。</span></p>
<p><span><font face="Times New Roman">2</font></span><span>．</span><span><font face="Times New Roman">Windows </font></span><span>操作系统。</span></p>
<p><span><font face="Times New Roman">3</font></span><span>．</span><span><font face="Times New Roman">C/C++/VB</font></span><span>开发集成环境。</span></p>
<p><strong><span>四、实验题目</span></strong></p>
<p><span>本实验有两个小题。</span></p>
<p><strong><span>第一题：设计一个按时间片轮转法实现处理器调度的程序。</span></strong></p>
<p><strong><span>算法设计思想：</span></strong></p>
<p><span><font face="Times New Roman">(1) </font></span><span>假定系统有五个进程，每一个进程用一个进程控制块</span><span><font face="Times New Roman">PCB</font></span><span>来代表。进程控制块的格式为：</span></p>
<table border=1 cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>进程名</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>指针</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>要求运行时间</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>已运行时间</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>状态</span></p>
            </td>
        </tr>
    </tbody>
</table>
<p><span>其中，进程名——作为进程的标识，假设五个进程的进程名分别为</span><span><font face="Times New Roman">Q<sub>1</sub></font></span><span>，</span><span><font face="Times New Roman">Q<sub>2</sub></font></span><span>，</span><span><font face="Times New Roman">Q<sub>3</sub></font></span><span>，</span><span><font face="Times New Roman">Q<sub>4</sub></font></span><span>，</span><span><font face="Times New Roman">Q<sub>5</sub></font></span><span>。</span></p>
<p><span>指针——进程按顺序排成循环队列，用指针指出下一个进程的进程控制块的首地址，最后一个进程的指针指出第一个进程的进程控制块首地址。</span></p>
<p><span>要求运行时间——假设进程需要运行的单位时间数。</span></p>
<p><span>已运行时间——假设进程已经运行的单位时间数，初始值为&#8220;</span><span><font face="Times New Roman">0</font></span><span>&#8221;。</span></p>
<p><span>状态——有两种状态，&#8220;就绪&#8221;和&#8220;结束&#8221;，初始状态都为&#8220;就绪&#8221;，用&#8220;</span><span><font face="Times New Roman">R</font></span><span>&#8221;表示。当一个进程运行结束后，它的状态为&#8220;结束&#8221;，用&#8220;</span><span><font face="Times New Roman">E</font></span><span>&#8221;表示。</span></p>
<p><span><font face="Times New Roman">(2) </font></span><span>每次运行所设计的进程调度程序前，为每个进程任意确定它的&#8220;要求运行时间&#8221;。</span></p>
<p><span><font face="Times New Roman">(3) </font></span><span>把五个进程按顺序排成循环队列，用指针指出队列连接情况。另用一标志单元记录轮到运行的进程。例如，当前轮到</span><span><font face="Times New Roman">P<sub>2</sub></font></span><span>执行，则有：</span></p>
<p><span>标志单元</span></p>
<p><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp; </span><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>K<sub>2</sub><span>&nbsp;&nbsp;&nbsp; </span></span></font></span></p>
<table border=1 cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">K<sub>1</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">Q<sub>1</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>2</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">Q<sub>2</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">Q<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">Q<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>5</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">Q<sub>5</sub></font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>2</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>5</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>1</sub></font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">3</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">4</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">0</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">0</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">0</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">0</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB3</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB4</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB5</font></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p><span><font face="Times New Roman">&nbsp;</font></span></p>
<p><span><font face="Times New Roman">(4) </font></span><span>处理器调度总是选择标志单元指示的进程运行。由于本实验是模拟处理器调度的功能，所以，对被选中的进程并不实际的启动运行，而是执行：</span></p>
<p align=center><span>已运行时间</span><span><font face="Times New Roman">+1</font></span></p>
<p><span>来模拟进程的一次运行，表示进程已经运行过一个单位的时间。</span></p>
<p><span>请注意：在实际的系统中，当一个进程被选中运行时，必须置上该进程可以运行的时间片值，以及恢复进程的现场，让它占有处理器运行，直到出现等待事件或运行满一个时间片。在这时省去了这些工作，仅用&#8220;已运行时间</span><span><font face="Times New Roman">+1</font></span><span>&#8221;来表示进程已经运行满一个时间片。</span></p>
<p><span><font face="Times New Roman">(5) </font></span><span>进程运行一次后，应把该进程的进程控制块中的指针值送到标志单元，以指示下一个轮到运行的进程。同时，应判断该进程的要求运行时间与已运行时间，若该进程的要求运行时间</span><span><span>?</span></span><span>已运行时间，则表示它尚未执行结束，应待到下一轮时再运行。若该进程的要求运行时间</span><span><font face="Times New Roman">=</font></span><span>已运行时间，则表示它已经执行结束，应指导它的状态修改成&#8220;结束&#8221;（</span><span><font face="Times New Roman">E</font></span><span>）且退出队列。此时，应把该进程的进程控制块中的指针值送到前面一个进程的指针位置。</span></p>
<p><span><font face="Times New Roman">(6) </font></span><span>若&#8220;就绪&#8221;状态的进程队列不为空，则重复上面的（</span><span><font face="Times New Roman">4</font></span><span>）和（</span><span><font face="Times New Roman">5</font></span><span>）的步骤，直到所有的进程都成为&#8220;结束&#8221;状态。</span></p>
<p><span><font face="Times New Roman">(7) </font></span><span>在所设计的程序中应有显示或打印语句，能显示或打印每次选中进程的进程名以及运行一次后进程队列的变化。</span></p>
<p><span><font face="Times New Roman">(8) </font></span><span>为五个进程任意确定一组&#8220;要求运行时间&#8221;，启动所设计的处理器调度程序，显示或打印逐次被选中的进程名以及进程控制块的动态变化过程。</span></p>
<p><span><font face="Times New Roman">&nbsp;</font></span></p>
<p><strong><span>第二题：设计一个按响应比高者优先调度算法实现进程调度的程序。</span></strong></p>
<p><strong><span>算法设计思想：</span></strong></p>
<p><span><font face="Times New Roman">&nbsp;(1) </font></span><span>假定系统有五个进程，每一个进程用一个进程控制块</span><span><font face="Times New Roman">PCB</font></span><span>来代表，进程控制块的格式为：</span></p>
<table border=1 cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>进程名</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>指针</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>要求运行时间</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>等待时间</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>响应比</span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=156>
            <p align=center><span>状态</span></p>
            </td>
        </tr>
    </tbody>
</table>
<p><span>其中，进程名——作为进程的标识，假设五个进程的进程名分别为</span><span><font face="Times New Roman">P<sub>1</sub></font></span><span>，</span><span><font face="Times New Roman">P<sub>2</sub></font></span><span>，</span><span><font face="Times New Roman">P<sub>3</sub></font></span><span>，</span><span><font face="Times New Roman">P<sub>4</sub></font></span><span>，</span><span><font face="Times New Roman">P<sub>5</sub></font></span><span>。</span></p>
<p><span>指针——按优先数的大小把五个进程连成队列，用指针指出下一个进程的进程控制块的首地址，最后一个进程中的指针为&#8220;</span><span><font face="Times New Roman">0</font></span><span>&#8221;。</span></p>
<p><span>要求运行时间——假设进程需要运行的单位时间数。</span></p>
<p><span>等待时间——自最近一次调度运行至今等待的时间数，当进程被调度时等待时间清零。</span></p>
<p><span>响应比——进程调度程序运行前计算每个进程的响应比，调度时总是选取响应比大的进程先执行，每次执行一个固定的时间片。</span></p>
<p><span>状态——可假设有两种状态，&#8220;就绪&#8221;状态和&#8220;结束&#8221;状态。五个进程的初始状态都为&#8220;就绪&#8221;，用&#8220;</span><span><font face="Times New Roman">R</font></span><span>&#8221;表示，当一个进程运行结束后，它的状态为&#8220;结束&#8221;，用&#8220;</span><span><font face="Times New Roman">E</font></span><span>&#8221;表示。</span></p>
<p><span><font face="Times New Roman">(2) </font></span><span>在每次运行你所设计的处理器调度程序之前，为每个进程任意确定它的&#8220;等待时间&#8221;和&#8220;要求运行时间&#8221;。</span></p>
<p><span><font face="Times New Roman">(3) </font></span><span>为了调度方便，把五个进程按给定的响应比从大到小连成队列。用一单元指出队首进程，用指针指出队列的连接情况。例：</span></p>
<p><span><span><font face="Times New Roman">&nbsp; </font></span></span><span>队首标志</span></p>
<p><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp; </span><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>K<sub>2</sub><span>&nbsp;&nbsp;&nbsp; </span></span></font></span></p>
<table border=1 cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">K<sub>1</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">P<sub>1</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>2</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">P<sub>2</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">P<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">P<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;K<sub>5</sub></font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">P<sub>5</sub></font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">0</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>4</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>5</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>3</sub></font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">K<sub>1</sub></font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">3</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">4</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">5</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">3</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">4</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">2</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">R</font></span></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=31>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB1</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB2</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB3</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB4</font></span></p>
            </td>
            <td vAlign=top width=39>
            <p><span><font face="Times New Roman">&nbsp;</font></span></p>
            </td>
            <td vAlign=top width=57>
            <p align=center><span><font face="Times New Roman">PCB5</font></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p><span><font face="Times New Roman">&nbsp;</font></span></p>
<p><span><font face="Times New Roman">(4) </font></span><span>处理器调度总是选队首进程运行。采用动态改变响应比的办法，进程每运行一次重新计算各进程的响应比。由于本实验是模拟处理器调度，所以，对被选中的进程并不实际的启动运行，而是执行：要求运行时间</span><span><font face="Times New Roman">-1</font></span><span>、等待时间为</span><span><font face="Times New Roman">0</font></span><span>。其它进程等待时间</span><span><font face="Times New Roman">+1</font></span><span>，重新计算各进程的响应比，并从大到小排序。</span></p>
<p><span>提醒注意的是：在实际的系统中，当一个进程被选中运行时，必须恢复进程的现场，让它占有处理器运行，直到出现等待事件或运行结束。在这里省去了这些工作。</span></p>
<p><span><font face="Times New Roman">(5) </font></span><span>进程运行一次后，若要求运行时间</span><span><span>?</span></span><span><font face="Times New Roman">0</font></span><span>，则再将它加入队尾（因其响应比最小。）；若要求运行时间</span><span><font face="Times New Roman">=0</font></span><span>，则把它的状态修改成&#8220;结束&#8221;（</span><span><font face="Times New Roman">E</font></span><span>），且退出队列。</span></p>
<p><span><font face="Times New Roman">(6) </font></span><span>若&#8220;就绪&#8221;状态的进程队列不为空，则重复上面（</span><span><font face="Times New Roman">4</font></span><span>）和（</span><span><font face="Times New Roman">5</font></span><span>）的步骤，直到所有进程都成为&#8220;结束&#8221;状态。</span></p>
<p><span><font face="Times New Roman">(7) </font></span><span>在所设计的程序中应有显示或打印语句，能显示或打印每次被选中进程的进程名以及运行一次后进程队列的变化及各进程的参数。</span></p>
<span>(8) </span><span>为五个进程任意确定一组&#8220;等待时间&#8221;和&#8220;要求运行时间&#8221;，启动所设计的进程调度程序，显示或打印逐次被选中进程的进程名以及进程控制块的动态变化过程。</span>
<img src ="http://www.cppblog.com/Icho/aggbug/123686.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 12:57 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123686.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OS 实验分类开篇语</title><link>http://www.cppblog.com/Icho/archive/2010/08/17/123685.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 04:56:00 GMT</pubDate><guid>http://www.cppblog.com/Icho/archive/2010/08/17/123685.html</guid><wfw:comment>http://www.cppblog.com/Icho/comments/123685.html</wfw:comment><comments>http://www.cppblog.com/Icho/archive/2010/08/17/123685.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Icho/comments/commentRss/123685.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Icho/services/trackbacks/123685.html</trackback:ping><description><![CDATA[<p>本学期学习了操作系统，实验课共有三个大实验，共有五个题目：时间片轮转法、高响应比优先、首次适应算法、位示图法、文件管理。每部分都会附上实验指导书和代码。每个实验都有点问题，请大家指教。</p>
<p>还有就是要提醒一下找到这里的学弟学妹，火哥可是知道我写代码的风格的，这些代码他也都看过，如果要用在实验作业上，请你们三思。</p>
<p>如果你们原封不动的复制粘贴，那就太令我失望了，师大的学风要上来啊。</p>
<img src ="http://www.cppblog.com/Icho/aggbug/123685.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Icho/" target="_blank">Brian</a> 2010-08-17 12:56 <a href="http://www.cppblog.com/Icho/archive/2010/08/17/123685.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>