Ejemplo n.º 1
0
        public void sort(int sel, int siz, process p)
        {
            process tmp = p;
            int n = siz;
            int x, y;
            for (x = 0; x < n; x++)
            {
                process tmp2 = tmp.get_next();
                for (y = 0; y < n-x- 1; y++)
                {
                    if (sel == 0) {
                        int c = tmp.get_aT()-tmp.get_timePassed();
                        int nn = tmp2.get_aT()-tmp.get_timePassed();
                        if (c > nn)
                        {
                            swap(tmp, tmp2);
                        }
                    }
                    else if (sel == 1)
                    {
                        
                        int c = tmp.get_bT()-tmp.get_bTimePassed();
                        int nn = tmp2.get_bT()-tmp2.get_bTimePassed();
                        if (c > nn)
                        {
                            swap(tmp, tmp2);
                        }
                    }
                    else if (sel == 2)
                    {

                        int c = tmp.get_priority();
                        int nn = tmp2.get_priority();
                        if (c > nn)
                        {
                            swap(tmp, tmp2);
                        }
                    }
                    tmp2 =tmp2.get_next();
                }
                tmp=tmp.get_next();
            }
        }
Ejemplo n.º 2
0
        public void swap(process tmp,process tmp2) {
            string tmpStr = tmp2.get_processName();
            int tmpAT = tmp2.get_aT();
            int tmpBT = tmp2.get_bT();
            int tmpPir = tmp2.get_priority();
            int tmpatp = tmp2.get_timePassed();
            int tmpbtp = tmp2.get_bTimePassed();
            tmp2.set_aT(tmp.get_aT());
            tmp2.set_bT(tmp.get_bT());
            tmp2.set_processName(tmp.get_processName());
            tmp2.set_priority(tmp.get_priority());
            tmp2.set_timePassed(tmp.get_timePassed());
            tmp2.set_bTimePassed(tmp.get_bTimePassed());
            tmp.set_aT(tmpAT);
            tmp.set_bT(tmpBT);
            tmp.set_processName(tmpStr);
            tmp.set_priority(tmpPir);
            tmp.set_timePassed(tmpatp);
            tmp.set_bTimePassed(tmpbtp);

        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                Form2 m = new Form2();
                m.Show();
                return;
            }
            ls.Add(textBox1.Text,
                   (int)numericUpDown1.Value,
                   (int)numericUpDown2.Value,
                   (int)numericUpDown3.Value);

            lsrr.Add(textBox1.Text,
                     (int)numericUpDown1.Value,
                     (int)numericUpDown2.Value,
                     (int)numericUpDown3.Value);
            process p = ls.get_process();

            listBox1.Items.Add(p.get_processName() + "\t" +
                               p.get_aT() + "\t" + p.get_bT() + "\t" + p.get_priority());
            pi++;
            textBox1.Text = "p" + pi;
        }