using the following allocate process function i need a deallocate process function but i dont know how to do it. :unsure: Could anyone help?
Here is the code:
sub allocateProcess()
{
my $found=0;
my $sizeNeeded=0;
my $spaceNotFound=0;
my $ID=0;
my $size=0;
system("clear");
print "Process ID: ";
$ID=<STDIN>;
chomp($ID);
for($i=0;$i<$processes;$i++)
{
if($processTable[$i]->ID == $ID)
{
$sizeNeeded=$processTable[$i]->size;
$found=1;
} ##if
} ##for
if($found==1)
{
for($i=$OS_SIZE;$i<$MAX_RAM;$i++)
{
if($ram[$i] == 0)
{
$spaceNotFound=0;
for($j=0;$j<$sizeNeeded;$j++)
{
if($i+$j<=$MAX_RAM)
{
if($ram[$i] != 0)
{
$spaceNotFound=1;
} #if
} #if
else
{
$spaceNotFound=1;
}
} ##for
if($spaceNotFound == 0)
{
for($x=0;$x<$sizeNeeded;$x++)
{
$ram[$x+$i]=$ID;
} #for
return;
} ##if
} ##if
} ###for
} ####if
elsif($found==0)
{
print "ID not found";
}
print "\n\n Press Return to continue...";
$continue=<STDIN>;
}