private void AddProcess(object o, EventArgs args)
 {
     BasicProcess process = new BasicProcess (Convert.ToInt32 (entries[0].Text), Convert.ToInt32 (entries[1].Text), Convert.ToInt32 (entries[2].Text), Convert.ToInt32 (entries[3].Text), Convert.ToInt32 (entries[4].Text), Convert.ToInt32 (entries[5].Text), Convert.ToInt32 (entries[6].Text));
     simulatorInterface.Processes.AddProcess (process);
     MainWindow.Store.AppendValues (process.ProcessId, process.ReadyTime, process.ExecutionTime, process.DeadlineTime, process.Priority, process.BlockingTime, process.BlockingLength);
     this.Destroy ();
 }
        public override BasicProcess Schedule(List<BasicProcess> processes)
        {
            BasicProcess result = new BasicProcess ();

            for (int i = 0; i < processes.Count; i++)
            {
                if (processes[i].State == Defines.Ready)
                {
                    if (result.ProcessId != 0)
                    {
                        if (processes[i].ReadyTime < result.ReadyTime)
                        {
                            result = processes[i];
                        }
                    }
                    else
                    {
                        result = processes[i];
                    }
                }
            }

            //			Console.WriteLine (this.ToString () + ": Selected Process: " + result.ProcessId);
            return result;
        }
Exemple #3
0
        /// <summary>
        /// Adds a process to the list
        /// </summary>
        /// <param name="process">
        /// A <see cref="BasicProcess"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public bool AddProcess(BasicProcess process)
        {
            bool result = true;

            // If List is empty
            if (this.Processes.Count == 0)
            {
                this.MaxProcessId = 0;
            }

            // Is the process passed as a paramater already in the list?
            if (!(this.Processes.Contains (process)))
            {
                this.MaxProcessId++; // Generate next process id
                process.ProcessId = this.MaxProcessId;
                process.Sort = process.ProcessId;

                this.Processes.Add (process);

                try
                {
                    BasicProcess runningProcess = new BasicProcess (process);
                    if (this.RunningProcesses.Count == 0)
                    {
                        this.RunningProcessesReset ();
                    }
                    else
                    {
                        this.RunningProcesses.Add (runningProcess);
                    }
                }
                catch (Exception e)
                {
                    if (Defines.DebugMode)
                    {
                        Console.WriteLine ("ProcessList: Exception: " + e.ToString ());
                    }
                }
            }
            else
            {
                result = false;
            }
            return result;
        }
Exemple #4
0
 /// <summary>
 /// Constructor used to create a copy of an existing process
 /// </summary>
 /// <param name="process">
 /// A <see cref="BasicProcess"/>
 /// </param>
 public BasicProcess(BasicProcess process)
 {
     this.ProcessId = process.ProcessId;
     this.ReadyTime = process.ReadyTime;
     this.DeadlineTime = process.DeadlineTime;
     this.ExecutionTime = process.ExecutionTime;
     this.State = process.State;
     this.Priority = process.Priority;
     this.BlockingTime = process.BlockingTime;
     this.BlockingLength = process.BlockingLength;
 }
Exemple #5
0
 /// <summary>
 /// Resets the running process list, copying the processes from the Processes list.
 /// </summary>
 /// <returns>
 /// A <see cref="System.Boolean"/>
 /// </returns>
 public bool RunningProcessesReset()
 {
     bool result = false;
     this.RunningProcesses = new List<BasicProcess> ();
     if (this.Processes.Count > 0)
     {
         try
         {
             for (int i = 0; i < this.Processes.Count; i++)
             {
                 BasicProcess proc = new BasicProcess (this.Processes[i]);
                 this.RunningProcesses.Add (proc);
             }
             result = true;
         }
         catch (Exception e)
         {
             if (Defines.DebugMode)
             {
                 Console.WriteLine ("ProcessList.RunningProcessesReset: Exception: " + e.ToString ());
                 this.RunningProcesses.Clear ();
             }
         }
     }
     else
     {
         result = false;
     }
     return result;
 }
Exemple #6
0
 /// <summary>
 /// Removes a process from the RunningProcesses list
 /// </summary>
 /// <param name="process">
 /// A <see cref="BasicProcess"/>
 /// </param>
 /// <returns>
 /// A <see cref="System.Boolean"/>
 /// </returns>
 public bool RemoveRunningProcess(BasicProcess process)
 {
     bool result = true;
     if (this.RunningProcesses.Contains (process))
     {
         this.RunningProcesses.Remove (process);
         result = true;
     }
     else
     {
         result = false;
     }
     return result;
 }
Exemple #7
0
        /// <summary>
        /// Removes a process from the list
        /// </summary>
        /// <param name="process">
        /// A <see cref="BasicProcess"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public bool RemoveProcess(BasicProcess process)
        {
            bool result = false;

            if (this.Processes.Contains (process))
            {
                if (process.ProcessId == this.MaxProcessId)
                {
                    this.MaxProcessId--;
                }
                this.Processes.Remove (process);
                result = true;
            }
            else
            {
                result = false;
            }
            // Removing of process from the RunningProcess list can only be done
            // using the RunningProcessesReset() method.
            return result;
        }
Exemple #8
0
 public bool Migrate(BasicProcess process)
 {
     return true;
 }