/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("Gantt Chart"); Console.WriteLine("_________________________________________________________________"); foreach (Process _tempProcess in ReadyQueue) { ExecuteProcess(_tempProcess); _tempProcess.IsCompleted = true; CompletedQueue.Add(_tempProcess); PreviousProcessEndTime = _tempProcess.EndTime; } Console.WriteLine("_________________________________________________________________"); }
/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("Gantt Chart"); Console.WriteLine("_________________________________________________________________"); double _tat = 0; double _wt = 0; while (ReadyQueue.Count > 0) { Process _tempProcess = ReadyQueue[0] as Process; double _originalBurst = _tempProcess.Burst; if (_tempProcess.RRStart.Equals(0) && _tempProcess.RRBurst.Equals(0)) { _tempProcess.RRStart = Counter; } if (_tempProcess.RRBurst.Equals(0)) { _tempProcess.RRBurst = _originalBurst; } _tempProcess.Burst = Quanta; ExecuteProcess(_tempProcess); _tempProcess.Burst = _originalBurst - Quanta; if (_tempProcess.Burst <= 0) { _tempProcess.IsCompleted = true; _tempProcess.Burst = _tempProcess.RRBurst; _tempProcess.StartTime = _tempProcess.RRStart; _tempProcess.EndTime = Counter; _tempProcess.WaitTime = _tempProcess.TurnAroundTime - _tempProcess.Burst; PreviousProcessEndTime = _tempProcess.EndTime; _tat += _tempProcess.TurnAroundTime; _wt += _tempProcess.WaitTime; ReadyQueue.Remove(_tempProcess); CompletedQueue.Add(_tempProcess); } else { PreviousProcessEndTime = Counter; ReadyQueue = ReadyQueue.Skip(1).Concat(ReadyQueue.Take(1)).ToList(); } } TotalTurnAroundTime = _tat; TotalWaitTime = _wt; Console.WriteLine("_________________________________________________________________"); }
/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("_________________________________________________________________"); while (true) { int _tempProcessId = -1; int _minEnter = Counter + 1; //Process entering later than Clock is under IO or waiting. bool _isDone = ReadyQueue.All(x => x.IsCompleted); for (int _index = 0; _index < ReadyQueue.Count; _index++) { if (ReadyQueue[_index].IsStarted && !ReadyQueue[_index].IsCompleted && ReadyQueue[_index].EnterTime < _minEnter) { _tempProcessId = _index; _minEnter = ReadyQueue[_index].EnterTime; } } if (_tempProcessId >= 0) { Process _executedProcess = ExecuteProcess(ReadyQueue[_tempProcessId]); if (_executedProcess.IsCompleted) { CompletedQueue.Add(_executedProcess); } } else { if (!_isDone) { Counter += 5; CPUWaitingTime += 5; } else { break; } } } CompletedQueue = CompletedQueue.OrderBy(x => x.Name).ToList(); Console.WriteLine("_________________________________________________________________"); }
/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("_________________________________________________________________"); while (true) { int _tempProcessId = -1; int _shortest = int.MaxValue; bool _isDone = ReadyQueue.All(x => x.IsCompleted); for (int _index = 0; _index < ReadyQueue.Count; _index++) { if (ReadyQueue[_index].IsStarted && !ReadyQueue[_index].IsCompleted && ReadyQueue[_index].ExpectedCPUBurst < _shortest && ReadyQueue[_index].EnterTime < Counter) { _tempProcessId = _index; _shortest = ReadyQueue[_index].Burst; } } if (_tempProcessId >= 0) { Process _executedProcess = ExecuteProcess(ReadyQueue[_tempProcessId]); if (_executedProcess.IsCompleted) { CompletedQueue.Add(_executedProcess); } } else { if (!_isDone) { Counter += 5; CPUWaitingTime += 5; } else { break; } } } CompletedQueue = CompletedQueue.OrderBy(x => x.Name).ToList(); Console.WriteLine("_________________________________________________________________"); }
/// <summary> /// This is entry point of the execution of the algorithm from outside the world. /// </summary> public override void ExecuteAlgorithm() { Console.WriteLine("_________________________________________________________________"); while (true) { int _processId = -1; bool _isDone = ReadyQueue.All(x => x.IsCompleted); for (int _index = 0; _index < ReadyQueue.Count; _index++) { if (!ReadyQueue[_index].IsCompleted && ReadyQueue[_index].EnterTime < Counter) { Counter += ContextSwitch; CPUWaitingTime += ContextSwitch; _processId = _index; Process _executedProcess = ExecuteProcess(ReadyQueue[_index]); if (_executedProcess.IsCompleted) { CompletedQueue.Add(_executedProcess); } } } if (_processId.Equals(-1)) { if (!_isDone) { Counter += 5; CPUWaitingTime += 5; } else { break; } } } CompletedQueue = CompletedQueue.OrderBy(x => x.Name).ToList(); Console.WriteLine("_________________________________________________________________"); }