操作系统大作业(银行家算法)


操作系统课程设计银行家算法(vs 20005)
资源截图
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Regularexpressions;

namespace weq
{
    public class OperatingSystem
    {
        #region...声明程序所需要的各个变量
        public int totalPro = 5; //进程数
        public int totalRes = 3; //资源数
        public int id = -1;

        public int[] Available;
        public int[][] Max;

        public int[][] Allocation;
        public int[][] Need;
        public int[] Requesti;
        
        #endregion

        #region...默认构造函数
        public OperatingSystem()
        {
            Initialize();
        }
        #endregion

        #region...初始化进程和资源数目以及申请资源数
        /// 
        /// 初始化各个变量
        /// 

        public void Initialize()
        {
            #region...获取输入进程以及资源数目

            do
            {
                Console.Write(“请输入请求资源的进程个数: “);
            }
            while (!Int32.TryParse(Console.ReadLine() out totalPro));

            do
            {
                Console.Write(“请输入的资源个数: “);
            }
            while (!Int32.TryParse(Console.ReadLine() out totalRes));

            #endregion

            #region...初始化各个数组

            Available = new int[totalRes];
            Console.Write(“请分别输入“ + totalRes+ “个资源的剩余数(中间以空格隔开例如:3 2 2):“);

            InitOneDimensionArray(Available);

            Max = new int[totalPro][];
            for (int i = 0; i < totalPro; i++)
            {
                Max[i] = new int[totalRes];
            }

            Allocation = new int[totalPro][];
            for (int i = 0; i < totalPro; i++)
            {
                Allocation[i] = new int[totalRes];
            }

            Need = new int[totalPro][];
            for (int i = 0; i < totalPro; i++)
            {
                Need[i] = new int[totalRes];
            }



            Console.WriteLine(“请输入各个进程对各类资源的最大需求数(“ + totalPro + “行“ + totalRes+ “列“ + “每行数字中间以空格隔开例如:3 2 2):“);
            InitMaxtrixArray(Max);
            Console.WriteLine(“请输入各个进程已分配各类资源数(“ + totalPro + “行“ + totalRes+ “列“ + “):“);
            InitMaxtrixArray(Allocation);


            for (int i = 0; i < totalPro; i++)
            {
                for (int j = 0; j < totalRes; j++)
                {
                    Need[i][j] = Max[i][j] - Allocation[i][j];
                }
            }
            #endregion

            #region... 申请资源的进程以及数目
            do
            {
                Console.WriteLine(“选择当前提出请求资源的进程0-“ + (totalPro - 1) + “:“);
            }
            while (!(int.TryParse(Console.ReadLine().Trim() out id) && id >= 0 && id < (totalPro - 1)));

            Requesti = new int[totalRes];

            Console.WriteLine(“请分别输入“ + id + “号进程对这“ + totalRes+ “个资源的申请量(数据格式如:3 2 2):“);

            InitOneDimensionArray(Requesti);
            #endregion
        }

        #endregion

        #region...... 初始化各个数组

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     169527  2009-07-02 19:54  OSOSinDebugffl.ico

     文件      20480  2009-12-29 21:46  OSOSinDebugOS.exe

     文件      19968  2009-12-29 21:46  OSOSinDebugOS.pdb

     文件       5632  2005-12-08 14:51  OSOSinDebugOS.vshost.exe

     文件      20480  2009-12-29 21:46  OSOSinReleaseOS.exe

     文件      17920  2009-12-29 21:46  OSOSinReleaseOS.pdb

     文件       5632  2005-12-08 14:51  OSOSinReleaseOS.vshost.exe

     文件      20480  2009-12-29 21:46  OSOSobjDebugOS.exe

     文件      19968  2009-12-29 21:46  OSOSobjDebugOS.pdb

     文件        238  2009-12-29 21:47  OSOSobjOS.csproj.FileList.txt

     文件      20480  2009-12-29 21:46  OSOSobjReleaseOS.exe

     文件      17920  2009-12-29 21:46  OSOSobjReleaseOS.pdb

     文件       8235  2009-12-29 21:40  OSOSOperatingSystem.cs

     文件       1984  2009-12-29 21:40  OSOSOS.csproj

     文件       1071  2009-12-29 21:40  OSOSProgram.cs

     文件       1175  2009-12-29 21:39  OSOSPropertiesAssemblyInfo.cs

     文件     762880  2009-12-29 21:47  OSOS-SetupDebugOS-Setup.msi

     文件     422912  2009-12-29 21:47  OSOS-SetupDebugsetup.exe

     文件      29376  2009-12-29 21:46  OSOS-SetupOS-Setup.vdproj

     文件     762368  2009-12-29 21:46  OSOS-SetupReleaseOS-Setup.msi

     文件     422912  2009-12-29 21:46  OSOS-SetupReleasesetup.exe

     文件       1193  2009-12-29 21:44  OSOS.sln

    ..A..H.     12800  2009-12-29 21:48  OSOS.suo

     目录          0  2009-12-29 21:53  OSOSobjDebugTempPE

     目录          0  2009-12-29 21:53  OSOSobjReleaseTempPE

     目录          0  2009-12-29 21:53  OSOSinDebug

     目录          0  2009-12-29 21:53  OSOSinRelease

     目录          0  2009-12-29 21:53  OSOSobjDebug

     目录          0  2009-12-29 21:53  OSOSobjRelease

     目录          0  2009-12-29 21:53  OSOSin

............此处省略10个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)