@@ -126,11 +126,19 @@ def __init__(self, master):
126
126
def setBT (self , value ):
127
127
self .BTSlider_CurValue .configure (text = math .trunc (value ))
128
128
129
- def generateGC_PPS (self ):
130
- pass
129
+ def generateGC_PPS (self , completed_list , start_times , end_times ):
130
+ fig , ax = plt .subplots ()
131
+ for i , process in enumerate (completed_list ):
132
+ start_time = start_times [i ]
133
+ end_time = end_times [i ]
134
+ process_name = process [0 ]
135
+ ax .barh (process_name , end_time - start_time , left = start_time , label = process_name )
131
136
137
+ ax .set_xlabel ('Time' , fontsize = 9 )
138
+ ax .legend (loc = 'center left' , bbox_to_anchor = (1.0 , 0.5 ))
139
+ plt .grid (axis = 'x' )
140
+ plt .savefig ("./GANTT_OUTPUT/GTChart.png" , bbox_inches = 'tight' , dpi = 100 )
132
141
def GenerateGANTT_Chart (self , process_Timing ):
133
-
134
142
fig , ax = plt .subplots ()
135
143
for i , (process , timings ) in enumerate (process_Timing .items ()):
136
144
start , end = timings
@@ -146,17 +154,22 @@ def GenerateGANTT_Chart(self, process_Timing):
146
154
147
155
def startExecution (self ):
148
156
global NP
157
+ global WT
158
+ global TT
149
159
NP = int (self .Process_Input .get ())
150
160
if self .AlgoMenu .get () == "Preemptive Priority Scheduling" :
151
- global WT
152
- global TT
161
+
153
162
processList = self .PPS_Instance .inputRandom (int (self .Process_Input .get ()), math .trunc (self .Burst_Time .get ()))
163
+ completed_list = self .PPS_Instance .schedulingProcess ()
164
+ WT = self .PPS_Instance .waitingTime
165
+ TT = self .PPS_Instance .turnaroundTime
166
+ start_times = self .PPS_Instance .start_times
167
+ end_times = self .PPS_Instance .end_times
168
+ self .generateGC_PPS (completed_list , start_times , end_times )
154
169
155
170
156
171
157
172
elif self .AlgoMenu .get () == "Non-Preemtive Priotity Scheduling" :
158
- global WT
159
- global TT
160
173
processList = self .PPS_Instance .inputRandom (int (self .Process_Input .get ()), math .trunc (self .Burst_Time .get ()))
161
174
processTiming = self .NonPPS_Instance .Execute (processList )
162
175
WT = self .NonPPS_Instance .waitingTime
0 commit comments