示例#1
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            cbShowMessages.Enabled = true;
            pnlMemory.Enabled      = true;
            gbResQu1.Enabled       = false;
            gbResQu2.Enabled       = false;
            gbResQu3.Enabled       = false;
            gbRes1.Enabled         = false;
            gbRes2.Enabled         = false;
            gbRes3.Enabled         = false;
            pnlParameters.Enabled  = true;
            btnNext.Enabled        = false;
            btnStop.Enabled        = false;
            btnStart.Enabled       = true;
            lbRes1.Items.Clear();
            lbRes2.Items.Clear();
            lbRes3.Items.Clear();
            lbResQu1.Items.Clear();
            lbResQu2.Items.Clear();
            lbResQu3.Items.Clear();
            lbMemory.Items.Clear();

            lbCpu.Items.Clear();
            lbQueue.Items.Clear();
            lbStats.Items.Clear();

            cpu   = null;
            cpSch = null;
            st    = null;
            timer = null;
            queue = null;
            resSh = null;
            memSh = null;
        }
示例#2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            cbShowMessages.Enabled = false;
            pnlMemory.Enabled      = false;
            pnlParameters.Enabled  = false;
            btnNext.Enabled        = true;
            btnStop.Enabled        = true;
            btnStart.Enabled       = false;


            rnd      = new Random();
            ResCount = Convert.ToInt32(numCountOfRes.Value);
            cpu      = new Cpu(Convert.ToInt32(numQuant.Value));
            timer    = new Timer();
            queue    = new PriorityQueue <Process>();
            cpSch    = new CpuScheduler(Convert.ToDouble(numIntensivity.Value), Convert.ToInt32(numInterval.Value), Convert.ToInt32(numPrDiapason.Value), ResCount, Convert.ToInt32(numBitSize.Value), cbShowMessages.Checked);
            st       = new Statistics();
            resSh    = new ResourceScheduler[ResCount];
            memSh    = new MemoryScheduler(Convert.ToInt32(numLayers.Value));
            DisplayStats();
            DisplayMemory();


            for (int i = 0; i <= ResCount; i++)
            {
                if (i != ResCount)
                {
                    resSh[i] = new ResourceScheduler(Convert.ToInt32(numInterval.Value));
                    resSh[i].EvEndResource += new ResourceScheduler.Delegate1(st.HndFinishRes);
                }
                switch (i)
                {
                case 1:
                    gbRes1.Enabled = true; gbResQu1.Enabled = true; break;

                case 2:
                    gbRes2.Enabled = true; gbResQu2.Enabled = true; break;

                case 3:
                    gbRes3.Enabled = true; gbResQu3.Enabled = true; break;
                }
            }

            cpSch.EvNewProc      += new CpuScheduler.Delegate1(st.HndNewProc);
            cpSch.EvNewLength    += new CpuScheduler.Delegate2(st.HndNewLengthOfQueue);
            cpSch.EvProcIsFree   += new CpuScheduler.Delegate1(st.HndProcIsFree);
            cpSch.EvFinishedProc += new CpuScheduler.Delegate3(st.HndFinishProc);
            cpSch.EvDenied       += new CpuScheduler.Delegate1(st.HndDeniedProcess);
            cpSch.EvLeftProc     += new CpuScheduler.Delegate1(st.HndLeftProcess);
            //cpSch.CreateProcess(timer.NumOfTakt, queue);
            //DisplayQueue();
        }