Exemplo n.º 1
0
        public bool newProgress(string name, List <int> vector)
        {
            //判断是否超过resCount向量,若超过,返回false报错
            List <int> resCountList = resCount.getDataList();

            if (!BankerHelper.VectorLess(vector, resCountList))
            {
                LogoutEventArgs e = new LogoutEventArgs("error: 新建进程的最大需求资源数超过最大资源数.");
                Logout.NewMsg(e);
                return(false);
            }

            if (max.newRow(name))
            {
                //修改max
                max.modify(name, vector);
                need.newRow(name);
                allocation.newRow(name);
                //增加进程数
                progNum++;

                //计算need矩阵的值
                List <List <Int32> > t = new List <List <int> >();
                for (int i = 0; i < progNum; i++)
                {
                    t.Add(new List <int>());
                    for (int j = 0; j < resNum; j++)
                    {
                        t[i].Add(0);
                    }
                }
                BankerHelper.MatrixRed(max.getData(), allocation.getData(), ref t);
                need.modify(t);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public void newRes()
        {
            resNum++;
            resCount.newColumn();
            available.newColumn();
            max.newColumn();
            allocation.newColumn();
            need.newColumn();
            workAllocation.newColumn();

            //计算need矩阵的值
            List <List <Int32> > t = new List <List <int> >();

            for (int i = 0; i < progNum; i++)
            {
                t.Add(new List <int>());
                for (int j = 0; j < resNum; j++)
                {
                    t[i].Add(0);
                }
            }
            BankerHelper.MatrixRed(max.getData(), allocation.getData(), ref t);
            need.modify(t);
        }