1,105,534 Community Members

HELP: allocateprocess() to deallocateprocess()

Member Avatar
rozalla2002
Newbie Poster
1 post since Apr 2003
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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;
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article