PHP Program
NPP(Non Preemptive) Scheduling with Arrival Time
And
Gantt Chart
<?php
$count=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
}
if(isset($_POST["solve"]))
{
for($x=1;$x<=$count;$x++)
{
$count=$_POST['count'];
$job[$x][0]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=$_POST['at'.$x];
$job[$x][6]=$_POST['pn'.$x];
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
for($x=1;$x<=$count;$x++)
{
if($count2<=$job[$x][2])
{
$count2=$job[$x][2];
}
$hold=$count2+$job[$x][1];
for($y=$count2;$y<$hold;$y++)
{
$count2++;
}
$job[$x][3]=$count2;
$job[$x][4]=$job[$x][3]-$job[$x][2];
$job[$x][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
$job[0][3]=0;
for($x=1;$x<=$count;$x++)
{
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=1;$y<=$job[$x][3];$y++)
{
if($job[$x][2]>$job[$x-1][3])
{
$hold2=$job[$x][2];
}
else
{
$hold2=$job[$x-1][3];
}
if(($y>$hold2 AND $x!=1) OR $x==1)
{
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php } else { ?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
?>
<br>
<?php
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Priority Number</th>
<th>Finish Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][3]; ?></th>
<th><?php echo $job[$x][6]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Arrival Time</th>
<th>Burst Time</th>
<th>Priority Number</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="at<?php echo $x; ?>" name="at<?php echo $x; ?>" placeholder="at<?php echo $x; ?>"></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
<th><input type="text" id="pn<?php echo $x; ?>" name="pn<?php echo $x; ?>" placeholder="pn<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
Sunday, July 24, 2016
SJF(Shortest Job First) Scheduling Codes
PHP Program
SJF(Shortest Job First) Scheduling
And
Gantt Chart
<?php
$count=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
}
if(isset($_POST["solve"]))
{
for($x=1;$x<=$count;$x++)
{
$count=$_POST['count'];
$job[$x][0]=$x;
$sort[$x]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=0;
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
for($x=1;$x<=$count;$x++)
{
for($y=1;$y<=$count;$y++)
{
if($job[$y+1][1]<$job[$y][1] && $y<$count)
{
$temp2=$job[$y][1];
$job[$y][1]=$job[$y+1][1];
$job[$y+1][1]=$temp2;
$temp1=$job[$y][0];
$job[$y][0]=$job[$y+1][0];
$job[$y+1][0]=$temp1;
}
$temp1=0;
$temp2=0;
}
}
for($x=1;$x<=$count;$x++)
{
if($count2<$job[$x][2])
{
$count2=$job[$x][2];
}
$hold=$count2+$job[$x][1];
for($y=$count2;$y<$hold;$y++)
{
$count2++;
}
$job[$x][3]=$count2;
$job[$x][4]=$job[$x][3]-$job[$x][2];
$job[$sort[$x]][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
$job[0][3]=0;
for($x=1;$x<=$count;$x++)
{
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=1;$y<=$job[$x][3];$y++)
{
if($job[$x][2]>$job[$x-1][3])
{
$hold2=$job[$x][2];
}
else
{
$hold2=$job[$x-1][3];
}
if(($y>$hold2 AND $x!=1) OR $x==1)
{
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php } else { ?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
?>
<br>
<?php
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Finish Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][3]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
SJF(Shortest Job First) Scheduling
And
Gantt Chart
<?php
$count=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
}
if(isset($_POST["solve"]))
{
for($x=1;$x<=$count;$x++)
{
$count=$_POST['count'];
$job[$x][0]=$x;
$sort[$x]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=0;
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
for($x=1;$x<=$count;$x++)
{
for($y=1;$y<=$count;$y++)
{
if($job[$y+1][1]<$job[$y][1] && $y<$count)
{
$temp2=$job[$y][1];
$job[$y][1]=$job[$y+1][1];
$job[$y+1][1]=$temp2;
$temp1=$job[$y][0];
$job[$y][0]=$job[$y+1][0];
$job[$y+1][0]=$temp1;
}
$temp1=0;
$temp2=0;
}
}
for($x=1;$x<=$count;$x++)
{
if($count2<$job[$x][2])
{
$count2=$job[$x][2];
}
$hold=$count2+$job[$x][1];
for($y=$count2;$y<$hold;$y++)
{
$count2++;
}
$job[$x][3]=$count2;
$job[$x][4]=$job[$x][3]-$job[$x][2];
$job[$sort[$x]][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
$job[0][3]=0;
for($x=1;$x<=$count;$x++)
{
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=1;$y<=$job[$x][3];$y++)
{
if($job[$x][2]>$job[$x-1][3])
{
$hold2=$job[$x][2];
}
else
{
$hold2=$job[$x-1][3];
}
if(($y>$hold2 AND $x!=1) OR $x==1)
{
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php } else { ?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
?>
<br>
<?php
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Finish Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][3]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
SJF(Shortest Job First) Scheduling with Arrival Time Codes
PHP Program
SJF(Shortest Job First) Scheduling with Arrival Time
And
Gantt Chart
<?php
$count=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
$hold3=0;
$hold4=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
}
if(isset($_POST["solve"]))
{
for($x=1;$x<=$count;$x++)
{
$count=$_POST['count'];
$job[$x][0]=$x;
$sort[$x]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=$_POST['at'.$x];
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
for($x=1;$x<$count;$x++)
{
$hold4=0;
for($y=1;$y<$count;$y++)
{
if($hold4<=$job[$y][2])
{
$hold4=$job[$y][2];
}
if($job[$y+1][1]<$job[$y][1] AND $hold4>=$job[$y+1][2] AND $job[$y][2]<=$job[$y+1][2])
{
$temp2=$job[$y][1];
$job[$y][1]=$job[$y+1][1];
$job[$y+1][1]=$temp2;
$temp1=$job[$y][0];
$job[$y][0]=$job[$y+1][0];
$job[$y+1][0]=$temp1;
$temp3=$job[$y][2];
$job[$y][2]=$job[$y+1][2];
$job[$y+1][2]=$temp3;
}
$hold4=$hold4+$job[$y][1];
}
}
for($x=1;$x<=$count;$x++)
{
if($count2<=$job[$x][2])
{
$count2=$job[$x][2];
}
$hold=$count2+$job[$x][1];
for($y=$count2;$y<$hold;$y++)
{
$count2++;
}
$job[$x][3]=$count2;
$job[$x][4]=$job[$x][3]-$job[$x][2];
$job[$x][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
$job[0][3]=0;
for($x=1;$x<=$count;$x++)
{
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=1;$y<=$job[$x][3];$y++)
{
if($job[$x][2]>$job[$x-1][3])
{
$hold2=$job[$x][2];
}
else
{
$hold2=$job[$x-1][3];
}
if(($y>$hold2 AND $x!=1) OR $x==1)
{
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php } else { ?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
?>
<br>
<?php
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Finish Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][3]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Arrival Time</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="at<?php echo $x; ?>" name="at<?php echo $x; ?>" placeholder="at<?php echo $x; ?>"></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
SJF(Shortest Job First) Scheduling with Arrival Time
And
Gantt Chart
<?php
$count=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
$hold3=0;
$hold4=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
}
if(isset($_POST["solve"]))
{
for($x=1;$x<=$count;$x++)
{
$count=$_POST['count'];
$job[$x][0]=$x;
$sort[$x]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=$_POST['at'.$x];
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
for($x=1;$x<$count;$x++)
{
$hold4=0;
for($y=1;$y<$count;$y++)
{
if($hold4<=$job[$y][2])
{
$hold4=$job[$y][2];
}
if($job[$y+1][1]<$job[$y][1] AND $hold4>=$job[$y+1][2] AND $job[$y][2]<=$job[$y+1][2])
{
$temp2=$job[$y][1];
$job[$y][1]=$job[$y+1][1];
$job[$y+1][1]=$temp2;
$temp1=$job[$y][0];
$job[$y][0]=$job[$y+1][0];
$job[$y+1][0]=$temp1;
$temp3=$job[$y][2];
$job[$y][2]=$job[$y+1][2];
$job[$y+1][2]=$temp3;
}
$hold4=$hold4+$job[$y][1];
}
}
for($x=1;$x<=$count;$x++)
{
if($count2<=$job[$x][2])
{
$count2=$job[$x][2];
}
$hold=$count2+$job[$x][1];
for($y=$count2;$y<$hold;$y++)
{
$count2++;
}
$job[$x][3]=$count2;
$job[$x][4]=$job[$x][3]-$job[$x][2];
$job[$x][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
$job[0][3]=0;
for($x=1;$x<=$count;$x++)
{
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=1;$y<=$job[$x][3];$y++)
{
if($job[$x][2]>$job[$x-1][3])
{
$hold2=$job[$x][2];
}
else
{
$hold2=$job[$x-1][3];
}
if(($y>$hold2 AND $x!=1) OR $x==1)
{
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php } else { ?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
?>
<br>
<?php
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Finish Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][3]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Arrival Time</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="at<?php echo $x; ?>" name="at<?php echo $x; ?>" placeholder="at<?php echo $x; ?>"></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
Round Robin Scheduling Codes
PHP Program
Round Robin Scheduling
And
Gantt Chart
<?php
$count=1;
$qt=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
$timer=0;
$ctr=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
$qt=$_POST['qt'];
}
if(isset($_POST["solve"]))
{
$qt=$_POST['qt'];
$count=$_POST['count'];
for($x=1;$x<=$count;$x++)
{
$job[$x][0]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=0;
$job[$x][4]=0;
$holder[$x][2]=0;
$job[$x][1]=$job[$x][1];
$ctr=
$btc[$x]=$job[$x][1];
$sort[$x]=$job[$x][1];
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
Quantum Time:<input type="text" name="qt" id="qt" placeholder="qt" value="<?php echo $qt; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
$sort[$count+1]=$sort[$count] ;
for($x=1;$x<=$count;$x++)
{
for($y=1;$y<=$count;$y++)
{
if($sort[$y+1]<$sort[$y] && $y<$count)
{
$temp2=$sort[$y];
$sort[$y]=$sort[$y+1];
$sort[$y+1]=$temp2;
}
$temp1=0;
$temp2=0;
}
}
$sort[$count]=ceil($sort[$count]/$qt);
for($z=1;$z<=$sort[$count];$z++)
{
for($x=1;$x<=$count;$x++)
{
$qtc=$qt;
if($btc[$x]<=0)
{
}
else
{
if($qt>$btc[$x])
{
$qtc=$btc[$x];
}
$holder[$x][1]=$timer;
$recat[$x][$z]=$timer;
$recat[$x][$z+1]=0;
$timer=$timer+$qtc;
$btc[$x]=$btc[$x]-$qtc;
$job[$x][4]=$job[$x][4]+($holder[$x][1]-$holder[$x][2]);
$holder[$x][2]=$timer;
$recft[$x][$z]=$timer;
$recft[$x][$z+1]=0;
}
}
}
for($x=1;$x<=$count;$x++)
{
$job[$x][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
for($x=1;$x<=$count;$x++)
{
$z=1;
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=0;$y<=$timer;$y++)
{
if($recat[$x][$z]<$y AND $recft[$x][$z]>=$y){
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php
} elseif($recft[$x][$z]<$y AND $recft[$x][$z]!=0) {
$z++;
?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
} else {
?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
echo "<br>";
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
Round Robin Scheduling
And
Gantt Chart
<?php
$count=1;
$qt=1;
$count2=0;
$count3=0;
$flag=0;
$ATT=0;
$AWT=0;
$hold=0;
$hold2=0;
$timer=0;
$ctr=0;
if(isset($_POST["submit"]))
{
$count=$_POST['count'];
$qt=$_POST['qt'];
}
if(isset($_POST["solve"]))
{
$qt=$_POST['qt'];
$count=$_POST['count'];
for($x=1;$x<=$count;$x++)
{
$job[$x][0]=$x;
$job[$x][1]=$_POST['bt'.$x];
$job[$x][2]=0;
$job[$x][4]=0;
$holder[$x][2]=0;
$job[$x][1]=$job[$x][1];
$ctr=
$btc[$x]=$job[$x][1];
$sort[$x]=$job[$x][1];
$flag=1;
}
}
?>
<form method="post">
Number of Jobs:<input type="text" name="count" id="count" placeholder="count" value="<?php echo $count; ?>"><br><br>
Quantum Time:<input type="text" name="qt" id="qt" placeholder="qt" value="<?php echo $qt; ?>"><br><br>
<input type="submit" id="submit" placeholder="submit" name="submit" value="Submit">
<br>
<input type="submit" name="solve" id="solve" placeholder="solve" value="Solve">
<br>
<br>
<?php
if($flag==1)
{
$sort[$count+1]=$sort[$count] ;
for($x=1;$x<=$count;$x++)
{
for($y=1;$y<=$count;$y++)
{
if($sort[$y+1]<$sort[$y] && $y<$count)
{
$temp2=$sort[$y];
$sort[$y]=$sort[$y+1];
$sort[$y+1]=$temp2;
}
$temp1=0;
$temp2=0;
}
}
$sort[$count]=ceil($sort[$count]/$qt);
for($z=1;$z<=$sort[$count];$z++)
{
for($x=1;$x<=$count;$x++)
{
$qtc=$qt;
if($btc[$x]<=0)
{
}
else
{
if($qt>$btc[$x])
{
$qtc=$btc[$x];
}
$holder[$x][1]=$timer;
$recat[$x][$z]=$timer;
$recat[$x][$z+1]=0;
$timer=$timer+$qtc;
$btc[$x]=$btc[$x]-$qtc;
$job[$x][4]=$job[$x][4]+($holder[$x][1]-$holder[$x][2]);
$holder[$x][2]=$timer;
$recft[$x][$z]=$timer;
$recft[$x][$z+1]=0;
}
}
}
for($x=1;$x<=$count;$x++)
{
$job[$x][5]=$job[$x][4]-$job[$x][1];
$ATT=$ATT+$job[$x][4];
$AWT=$AWT+$job[$x][5];
}
$ATT=$ATT/$count;
$AWT=$AWT/$count;
for($x=1;$x<=$count;$x++)
{
$z=1;
?>
Job:<?php echo $job[$x][0]; ?> :
<?php
for($y=0;$y<=$timer;$y++)
{
if($recat[$x][$z]<$y AND $recft[$x][$z]>=$y){
?>
<font style="background-color:#62<?php echo $x;?>4<?php echo $x;?>5" color="#62<?php echo $x;?>4<?php echo $x;?>5" > <?php echo $x;?> </font>
<?php
} elseif($recft[$x][$z]<$y AND $recft[$x][$z]!=0) {
$z++;
?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
} else {
?>
<font style="background-color:#FFFFFF" color="#FFFFFF"><?php echo $x;?></font>
<?php
}
}
echo "<br>";
}
?>
<br>
<br>
Average Turnaround Time: <?php echo $ATT; ?> <br>
Average Waiting Time: <?php echo $AWT; ?> <br>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
<th>Arrival Time</th>
<th>Turnaround Time</th>
<th>Waiting Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $job[$x][0]; ?></th>
<th><?php echo $job[$x][1]; ?></th>
<th><?php echo $job[$x][2]; ?></th>
<th><?php echo $job[$x][4]; ?></th>
<th><?php echo $job[$x][5]; ?></th>
</tr>
<?php }} else { ?>
<table border="1">
<tr>
<th>JobID</th>
<th>Burst Time</th>
</tr>
<?php
for($x=1;$x<=$count;$x++)
{
?>
<tr>
<th><?php echo $x ?></th>
<th><input type="text" id="bt<?php echo $x; ?>" name="bt<?php echo $x; ?>" placeholder="bt<?php echo $x; ?>"></th>
</tr>
<?php }} ?>
</table>
</form>
Subscribe to:
Posts (Atom)