Subversion Repositories programming

Rev

Rev 418 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 418 Rev 419
Line 179... Line 179...
179
    /**
179
    /**
180
     * Print a Gantt Chart detailing the results of this scheduler's run.
180
     * Print a Gantt Chart detailing the results of this scheduler's run.
181
     */
181
     */
182
    protected void printGanttChart ()
182
    protected void printGanttChart ()
183
    {
183
    {
184
        Vector<String> t = new Vector<String> ();
-
 
185
        Vector<String> l = new Vector<String> ();
184
        GanttChart gc = new GanttChart (log);
186
 
-
 
187
        String timeline = new String();
-
 
188
        String labels = new String();
-
 
189
        String add1 = new String();
-
 
190
        String add2 = new String();
-
 
191
 
-
 
192
        int exptime = 0;
185
        gc.printGanttChart ();
193
        int templen;
-
 
194
 
-
 
195
        for (LogEntry e : log)
-
 
196
        {
-
 
197
            if (e.msg == LogEntry.MsgType.ADDED)
-
 
198
                continue;
-
 
199
 
-
 
200
            if (e.msg == LogEntry.MsgType.EXPIRE || e.msg == LogEntry.MsgType.COMPLETE)
-
 
201
            {
-
 
202
                exptime = e.time;
-
 
203
                continue;
-
 
204
            }
-
 
205
 
-
 
206
            add1 = "|---" + e.proc.name + "---";
-
 
207
            add2 = "" + e.time;
-
 
208
 
-
 
209
            for (int i=0; add2.length() < add1.length(); i++)
-
 
210
                add2 += " ";
-
 
211
 
-
 
212
            if (timeline.length() + add1.length() > 79)
-
 
213
            {
-
 
214
                t.add (timeline + "|");
-
 
215
                templen = labels.length() - String.valueOf(exptime).length();
-
 
216
                labels = labels.substring (0, templen+1) + String.valueOf(exptime);
-
 
217
                l.add (labels);
-
 
218
 
-
 
219
                /* Clear the current timeline and labels */
-
 
220
                timeline = new String();
-
 
221
                labels = new String();
-
 
222
            }
-
 
223
 
-
 
224
            timeline += add1;
-
 
225
            labels += add2;
-
 
226
        }
-
 
227
 
-
 
228
        /* Done, add the last values of timeline and labels to the Vectors */
-
 
229
        t.add (timeline + "|");
-
 
230
        templen = labels.length() - String.valueOf(exptime).length();
-
 
231
        labels = labels.substring (0, templen+1) + String.valueOf(exptime);
-
 
232
        l.add (labels);
-
 
233
 
-
 
234
        assert (l.size() == t.size());
-
 
235
 
-
 
236
        for (int i=0; i<l.size(); i++)
-
 
237
        {
-
 
238
            System.out.println (t.elementAt (i));
-
 
239
            System.out.println (l.elementAt (i));
-
 
240
            System.out.println ();
-
 
241
        }
-
 
242
    }
186
    }
243
 
187
 
244
    /**
188
    /**
245
     * Find the average wait time of processes.
189
     * Find the average wait time of processes.
246
     */
190
     */