private void process()
 {
     if (running)
     {
         for (int i = 0; i < waiting.Count; i++)
         {
             PropertiesData propertiesData = waiting[i];
             if (scheduler.SchedulerTime >= propertiesData.ArrivalTime)
             {
                 arrived.Add(propertiesData);
                 waiting.Remove(propertiesData);
             }
         }
         if (!processing)
         {
             if (arrived.Count > 0)
             {
                 float minPriority = arrived[0].Priority;
                 CurrentlyProcessing = arrived[0];
                 foreach (PropertiesData processes in arrived)
                 {
                     if (processes.Priority < minPriority)
                     {
                         minPriority         = processes.Priority;
                         CurrentlyProcessing = processes;
                     }
                 }
                 arrived.Remove(CurrentlyProcessing);
                 processing      = true;
                 ProcessorFreeAt = Mathf.Min(CurrentlyProcessing.BurstTime, 1);
                 CurrentlyProcessing.remainingBurstTime -= ProcessorFreeAt;
                 chartMaker.GenerateChartElement(CurrentlyProcessing, scheduler.SchedulerTime);
             }
         }
         else
         {
             ProcessorFreeAt -= scheduler.SchedulerDeltaTime;
             if (ProcessorFreeAt <= 0)
             {
                 if (CurrentlyProcessing.remainingBurstTime <= 0)
                 {
                     float SpeedAdjustment = -ProcessorFreeAt;
                     scheduler.makeSummary(CurrentlyProcessing, SpeedAdjustment);
                 }
                 else
                 {
                     arrived.Add(CurrentlyProcessing);
                 }
                 processing = false;
                 if (waiting.Count == 0 && arrived.Count == 0)
                 {
                     running           = false;
                     scheduler.running = false;
                 }
             }
         }
     }
 }
 void process()
 {
     if (running)
     {
         foreach (PropertiesData propertiesData in waiting.ToArray())
         {
             if (scheduler.SchedulerTime >= propertiesData.ArrivalTime)
             {
                 arrived.Add(propertiesData);
                 waiting.Remove(propertiesData);
             }
         }
         if (!processing)
         {
             if (arrived.Count > 0)
             {
                 float minBurst = arrived[0].BurstTime;
                 CurrentlyProcessing = arrived[0];
                 foreach (PropertiesData processes in arrived.ToArray())
                 {
                     if (processes.BurstTime < minBurst)
                     {
                         minBurst            = processes.BurstTime;
                         CurrentlyProcessing = processes;
                     }
                 }
                 arrived.Remove(CurrentlyProcessing);
                 processing      = true;
                 ProcessorFreeAt = Mathf.Min(CurrentlyProcessing.BurstTime, 1);
                 CurrentlyProcessing.remainingBurstTime -= ProcessorFreeAt;
                 chartMaker.GenerateChartElement(CurrentlyProcessing, scheduler.SchedulerTime);
             }
         }
         if (processing)
         {
             if (ProcessorFreeAt <= 0)
             {
                 if (CurrentlyProcessing.remainingBurstTime <= 0)
                 {
                     scheduler.makeSummary(CurrentlyProcessing);
                 }
                 else
                 {
                     arrived.Add(CurrentlyProcessing);
                 }
                 processing = false;
                 if (waiting.Count == 0 && arrived.Count == 0)
                 {
                     scheduler.running = false;
                     running           = false;
                 }
             }
             ProcessorFreeAt -= scheduler.SchedulerDeltaTime;
         }
     }
 }
Ejemplo n.º 3
0
 private void process()
 {
     if (running)
     {
         for (int i = 0; i < waiting.Count; i++)
         {
             PropertiesData propertiesData = waiting[i];
             if (scheduler.SchedulerTime >= propertiesData.ArrivalTime)
             {
                 Ready.Enqueue(propertiesData);
                 waiting.Remove(propertiesData);
             }
         }
         if (!processing)
         {
             if (Ready.Count > 0)
             {
                 CurrentlyProcessing = Ready.Peek();
                 Ready.Dequeue();
                 processing      = true;
                 ProcessorFreeAt = Mathf.Min(CurrentlyProcessing.BurstTime, Tq);
                 CurrentlyProcessing.remainingBurstTime -= ProcessorFreeAt;
                 ProcessStartedAt = scheduler.SchedulerTime;
                 chartMaker.GenerateChartElement(CurrentlyProcessing, scheduler.SchedulerTime);
             }
         }
         else
         {
             ProcessorFreeAt -= scheduler.SchedulerDeltaTime;
             if (ProcessorFreeAt <= 0)
             {
                 if (CurrentlyProcessing.remainingBurstTime > 0)
                 {
                     Ready.Enqueue(CurrentlyProcessing);
                 }
                 else
                 {
                     float SpeedAdjustment = -ProcessorFreeAt;
                     scheduler.makeSummary(CurrentlyProcessing, SpeedAdjustment);
                 }
                 processing = false;
                 if (Ready.Count == 0 && waiting.Count == 0)
                 {
                     running           = false;
                     scheduler.running = false;
                 }
             }
         }
     }
 }
 void process()
 {
     if (running)
     {
         foreach (PropertiesData propertiesData in waiting.ToArray())
         {
             if (scheduler.SchedulerTime >= propertiesData.ArrivalTime)
             {
                 arrived.Add(propertiesData);
                 waiting.Remove(propertiesData);
             }
         }
         if (!processing)
         {
             if (arrived.Count > 0)
             {
                 float minPriority = arrived[0].Priority;
                 CurrentlyProcessing = arrived[0];
                 for (int i = 0; i < arrived.Count; i++)
                 {
                     PropertiesData processes = arrived[i];
                     if (processes.Priority < minPriority)
                     {
                         minPriority         = arrived[i].Priority;
                         CurrentlyProcessing = arrived[i];
                     }
                 }
                 arrived.Remove(CurrentlyProcessing);
                 processing      = true;
                 ProcessorFreeAt = CurrentlyProcessing.BurstTime;
                 chartMaker.GenerateChartElement(CurrentlyProcessing, scheduler.SchedulerTime);
             }
         }
         if (processing)
         {
             if (ProcessorFreeAt <= 0)
             {
                 scheduler.makeSummary(CurrentlyProcessing);
                 processing = false;
                 if (waiting.Count == 0 && arrived.Count == 0)
                 {
                     running           = false;
                     scheduler.running = false;
                 }
             }
             ProcessorFreeAt -= scheduler.SchedulerDeltaTime;
         }
     }
 }
 void process()
 {
     if (running)
     {
         for (int i = 0; i < waiting.Count; i++)
         {
             PropertiesData propertiesData = waiting[i];
             if (scheduler.SchedulerTime >= propertiesData.ArrivalTime)
             {
                 arrived.Enqueue(propertiesData);
                 waiting.Remove(propertiesData);
             }
         }
         if (!processing)
         {
             if (arrived.Count > 0)
             {
                 CurrentlyProcessing = arrived.Dequeue();
                 processing          = true;
                 ProcessorFreeAt     = CurrentlyProcessing.BurstTime;
                 chartMaker.GenerateChartElement(CurrentlyProcessing, scheduler.SchedulerTime);
             }
         }
         if (processing)
         {
             if (ProcessorFreeAt <= 0)
             {
                 float SpeedAdjustment = -ProcessorFreeAt;
                 scheduler.makeSummary(CurrentlyProcessing, SpeedAdjustment);
                 processing = false;
                 if (waiting.Count == 0 && arrived.Count == 0)
                 {
                     running           = false;
                     scheduler.running = false;
                 }
             }
             ProcessorFreeAt -= scheduler.SchedulerDeltaTime;
         }
     }
 }