void pullDown(ProcessX p)
        {
            ProcessX temp = pqs.ElementAt(p.queueNumber).ElementAt(0);

            pqs.ElementAt(p.queueNumber).Remove(temp);

            pqs.ElementAt(p.queueNumber + 1).AddLast(temp);
            p.queueNumber += 1;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // MessageBox.Show(clicked.ToString());
            proc[0, 0].Selected = false;

            //creating cols and rows in d1
            for (int i = 0; i < proc.Rows.Count + 1; i++)
            {
                d1.Columns.Add(new DataGridViewTextBoxColumn());
                for (int j = 0; j < maxProcessSize; j++)
                {
                    d1.Rows.Add("Q" + j.ToString());
                }
            }

            int    time        = 0;
            string processLine = "";

            ProcessX[] processes = new ProcessX[proc.Rows.Count];


            for (int i = 0; i < proc.Rows.Count; i++)
            {
                String proname   = (String)proc[0, i].Value.ToString();
                int    starttime = int.Parse(proc[1, i].Value.ToString());
                int    runtime   = int.Parse(proc[2, i].Value.ToString());

                processes[i] = new ProcessX(proname, starttime, runtime, i);
                timeline.Rows.Add(processes[i].id);
                proc[0, i].Style.BackColor = colors[processes[i].k];

                if (processes[i].serviceTime > maxProcessSize)
                {
                    maxProcessSize = processes[i].serviceTime;
                }
            }

            int numOfQueues = 0;

            foreach (ProcessX p in processes)
            {
                if (p.serviceTime > numOfQueues)
                {
                    numOfQueues = p.serviceTime;
                }
            }

            for (int i = 0; i < numOfQueues; i++)
            {
                pqs.AddLast(new LinkedList <ProcessX>());
            }


            bool allDone = true;

            while (allDone)
            {
                //**************printQueues(pqs);*******************uncomment to see process queues while updating

                allDone = false;
                foreach (ProcessX p in processes)
                {
                    if (p.remainingTime > 0)
                    {
                        allDone = true;
                        break;
                    }
                }

                foreach (ProcessX p in processes)
                {
                    if (p.arrivalTime == time) //pqs.ElementAt(0).ElementAt(0).serviceTime>0
                    {
                        pqs.ElementAt(0).AddLast(p);
                    }
                }
                //Console.WriteLine(processLine);
                //continue msg box
                // queueUpdater();
                time++;

                bool processRan = false;

                foreach (LinkedList <ProcessX> pl in pqs)
                {
                    queueUpdater();

                    if (pl.Count > 0)
                    {
                        MessageBox.Show(this, "Continue to next cycle?", "Continue?", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        processRan = true;
                        ProcessX nextProcessToRun = pl.ElementAt(0);
                        processLine += nextProcessToRun.id + " ";

                        int col = time;

                        int row = nextProcessToRun.k;

                        // label1.Text += (nextProcessToRun.id + " ");

                        timeline[col, row].Style.BackColor = colors[row];

                        nextProcessToRun.remainingTime--;
                        if (nextProcessToRun.remainingTime == 0)
                        {
                            LinkedList <ProcessX> a = pqs.ElementAt(nextProcessToRun.queueNumber);
                            a.Remove(a.ElementAt(0));
                        }
                        else if (processes[1].arrivalTime <= time)
                        {
                            pullDown(nextProcessToRun);
                        }

                        break;
                    }
                }
                if (!processRan)
                {
                    processLine += "_ ";
                }
            }
        }