Esempio n. 1
0
 private void RemoveProcess(ProcessControlBlock pcb)
 {
     lock (processes)
     {
         object[] items = new object[processes.Count];
         processes.CopyTo(items, 0);
         foreach (object o in items)
         {
             ProcessControlBlock old = (ProcessControlBlock)o;
             if (old.ID == pcb.ID)
             {
                 processes.Remove(o);
                 processes.Sort();
                 break;
             }
         }
     }
 }
Esempio n. 2
0
 /**This method facilitates Job Creation and regulates the Job Queue.
  * */
 private void Create()
 {
     ProcessControlBlock pcb = null;
     while (true)
     {
         if (jobQueue.Count < 3 && readyQueue.Count < 4)
         {
             pcb = new ProcessControlBlock(++counter);
             pcb.State = ProcessControlBlock.NEW;
             AddProcess(pcb);
             jobQueue.Enqueue(pcb);
             statusJob = "Created Process " + pcb.ID + ".";
         }
         Thread.Sleep(3000);
     }
 }
Esempio n. 3
0
        /**This method fills the DataGridView with PCB information.
         * */
        private void PropagateDB(ProcessControlBlock pcb)
        {
            string state = "";
            object[] values = null;
            DataGridViewRow row = new DataGridViewRow();
            row.HeaderCell.Value = pcb.ID + "";

            switch (pcb.State)
            {
                case ProcessControlBlock.READY:
                    state = "Ready";
                    break;
                case ProcessControlBlock.RUNNING:
                    state = "Running";
                    break;
                case ProcessControlBlock.WAITING:
                    state = "Waiting";
                    break;
                case ProcessControlBlock.TERMINATING:
                    state = "Terminating";
                    break;
                case ProcessControlBlock.INTERRUPTED:
                    state = "Interrupted";
                    break;
                default: return;
            }
            if (compactionToolStripMenuItem.Checked)
            {
                lock (compactionGridView)
                {
                    if (compactionGridView.ColumnCount == 5)
                    {
                        values = new object[] { pcb.BaseNum, pcb.Limit, pcb.MemSize, state, pcb.State == ProcessControlBlock.TERMINATING ? 0 : pcb.CPUTime };
                        row.CreateCells(compactionGridView, values);
                        compactionGridView.Rows.Add(row);
                    }
                }
            }
            else
            {
                lock (pagingGridView)
                {
                    if (pagingGridView.ColumnCount == 5)
                    {
                        values = new object[] { pcb.MemSize, pcb.Pages.Count, pcb.Request - pcb.Pages.Count, state, pcb.State == ProcessControlBlock.TERMINATING ? 0 : pcb.CPUTime };
                        row.CreateCells(pagingGridView, values);
                        pagingGridView.Rows.Add(row);
                    }
                }
            }
        }
Esempio n. 4
0
 /**Releases a process's hold on the CPU*/
 public void FreeCPU(bool newProcess)
 {
     timer.Dispose();
     if (newProcess)
     {
         isFree = true;
         pcb = null;
     }
 }
Esempio n. 5
0
 public void EnqueueProcess(ProcessControlBlock pcb)
 {
     processes.Enqueue(pcb);
 }