View Single Post

   
  #2 (permalink)  
Old 01-04-2008, 10:22 PM
Dan Foster
 
Posts: n/a
Default Re: Unix PIDS on AIX

In article <5f345ea8.0401190627.43959786@posting.google.com >, Vince Clarke <vincentfclarke@ntlworld.com> wrote:
> I'm currently porting a large 'C' application from a Sequent platform
> (Dynix 4.4.7) to IBM AIX 5.2.
>
> The application maintains a 30000 entry array which is used to store
> the status of pid processes running on the system. The states of these
> processes change depending on the activity of the process. However the
> AIX system uses pids in the range 1 to ~4000000000. Clearly I can't
> maintain such a large array in my system and need to find some way of
> managing the problem.


Why not? 0 to 4.2 billion can be represented as a single unsigned 32-bit
integer as a 'long' in C... I don't know the size of the array members, but
the process ID for 30,000 entries would be one 32-bit longword which would
occupy about 117KB of RAM alone, which doesn't seem bad. Even if a single
array member was about 30 bytes total times 30,000, that's still only 3.5
MB of RAM total...

You don't need to have it as array[pid]; it would be far more memory
efficient to maintain it as a singly or doubly-linked list, which isn't
hard or slow to traverse, especially if structured via binary tree insert,
traversal, or delete functions.

-Dan
Reply With Quote