rozalla2002 0 Newbie Poster

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&#40;$ID&#41;;

        for&#40;$i=0;$i<$processes;$i++&#41;
        &#123;
                if&#40;$processTable&#91;$i&#93;->ID == $ID&#41;
                &#123;
                        $sizeNeeded=$processTable&#91;$i&#93;->size;
                        $found=1;
                &#125; ##if
        &#125; ##for
        if&#40;$found==1&#41;
        &#123;
                for&#40;$i=$OS_SIZE;$i<$MAX_RAM;$i++&#41;
                &#123;
                        if&#40;$ram&#91;$i&#93; == 0&#41;
                        &#123;
                                $spaceNotFound=0;
                                for&#40;$j=0;$j<$sizeNeeded;$j++&#41;
                                &#123;
                                        if&#40;$i+$j<=$MAX_RAM&#41;
                                        &#123;
                                                if&#40;$ram&#91;$i&#93; != 0&#41;
                                                &#123;
                                                        $spaceNotFound=1;
                                                &#125; #if
                                        &#125; #if
                                        else
                                        &#123;
                                                $spaceNotFound=1;
                                        &#125;
                                &#125; ##for
                                if&#40;$spaceNotFound == 0&#41;
                                &#123;
                                        for&#40;$x=0;$x<$sizeNeeded;$x++&#41;
                                        &#123;
                                                $ram&#91;$x+$i&#93;=$ID;
                                        &#125; #for
                                        return;
                                &#125; ##if
                        &#125; ##if

                &#125; ###for
        &#125; ####if
        elsif&#40;$found==0&#41;
        &#123;
                print "ID not found";
        &#125;
        print "\n\n Press Return to continue...";
        $continue=<STDIN>;
&#125;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.