Skip to content

Commit d15d679

Browse files
committed
added code for gantt chart
1 parent 937f8ce commit d15d679

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#ignore input.php file
22
input.php
3+
4+
#ignore buffers
5+
buffer/

algo_sim.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,34 @@
4040
echo "<tr>".$str."</tr>";
4141
}
4242
echo "</table>";
43-
echo "<h3>AVERAGE WAITING TIME: ".$output[$num_proc]."<br>AVERAGE TURN-AROUND TIME: ".$output[$num_proc+1]."</h3>";
44-
echo "<h3>GANTT CHART<br>".$output[$num_proc+2]."<br>".$output[$num_proc+3]."</h3>";
43+
echo "<h4>AVERAGE WAITING TIME: ".$output[$num_proc]."<br>AVERAGE TURN-AROUND TIME: ".$output[$num_proc+1]."</h4>";
44+
echo "<h4>GANTT CHART<br></h4>";
45+
46+
echo "<table id=\"gantt_chart\">";
47+
$temp = explode(" ",$output[$num_proc+2]);
48+
$time = array_slice(explode(" ",$output[$num_proc+3]),1);
49+
$str="";
50+
51+
$i=0;
52+
$px=20;
53+
foreach ($temp as $result) {
54+
if( $i == 0)
55+
$str = $str."<th style=\"width:".(int)$time[$i]*$px."px\">P".$result."</th>";
56+
else
57+
$str = $str."<th style=\"width:".((int)$time[$i]-(int)$time[$i-1])*$px."px\">P".$result."</th>";
58+
$i++;
59+
}
60+
echo "<tr>".$str."</tr>";
61+
62+
$str="";
63+
$i=0;
64+
foreach ($time as $result) {
65+
if( $i == 0 )
66+
$str = $str."<td><div style=\"float:left;\">0</div><div style=\"float:right;\">".$result."</div></td>";
67+
else
68+
$str = $str."<td><div style=\"float:right\">".$result."</div></td>";
69+
$i++;
70+
}
71+
echo "<tr>".$str."</tr></table>";
4572

4673
?>

buffer/input.txt

Whitespace-only changes.

simulator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ function display_output() {
107107

108108
$_SESSION["algo_num"] = $algo_num;
109109

110-
echo "<br><br>";
110+
$algo_name;
111+
if ( $algo_num == 1)
112+
$algo_name = "FIRST COME FIRST SERVE";
113+
else if( $algo_num == 2)
114+
$algo_name = "SHORTEST JOB FIRST";
115+
else if ( $algo_num == 3)
116+
$algo_name = "ROUND ROBIN";
117+
else
118+
$algo_name = "PRIORITY SCHEDULING";
119+
echo "<h2 style=\"text-align:center\">".$algo_name."</h2><br>";
111120

112121
echo "<table id=\"input_tab\">";
113122
if ( $algo_num == 4 ) {

0 commit comments

Comments
 (0)