943,428 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 3222
  • Perl RSS
Apr 16th, 2003
0

HELP: allocateprocess() to deallocateprocess()

Expand Post »
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:
Perl Syntax (Toggle Plain Text)
  1. sub allocateProcess()
  2. {
  3. my $found=0;
  4. my $sizeNeeded=0;
  5. my $spaceNotFound=0;
  6. my $ID=0;
  7. my $size=0;
  8.  
  9. system("clear");
  10. print "Process ID: ";
  11. $ID=<STDIN>;
  12. chomp($ID);
  13.  
  14. for($i=0;$i<$processes;$i++)
  15. {
  16. if($processTable[$i]->ID == $ID)
  17. {
  18. $sizeNeeded=$processTable[$i]->size;
  19. $found=1;
  20. } ##if
  21. } ##for
  22. if($found==1)
  23. {
  24. for($i=$OS_SIZE;$i<$MAX_RAM;$i++)
  25. {
  26. if($ram[$i] == 0)
  27. {
  28. $spaceNotFound=0;
  29. for($j=0;$j<$sizeNeeded;$j++)
  30. {
  31. if($i+$j<=$MAX_RAM)
  32. {
  33. if($ram[$i] != 0)
  34. {
  35. $spaceNotFound=1;
  36. } #if
  37. } #if
  38. else
  39. {
  40. $spaceNotFound=1;
  41. }
  42. } ##for
  43. if($spaceNotFound == 0)
  44. {
  45. for($x=0;$x<$sizeNeeded;$x++)
  46. {
  47. $ram[$x+$i]=$ID;
  48. } #for
  49. return;
  50. } ##if
  51. } ##if
  52.  
  53. } ###for
  54. } ####if
  55. elsif($found==0)
  56. {
  57. print "ID not found";
  58. }
  59. print "\n\n Press Return to continue...";
  60. $continue=<STDIN>;
  61. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rozalla2002 is offline Offline
1 posts
since Apr 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Error in Wrox Book
Next Thread in Perl Forum Timeline: embPerl or PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC