delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/03/21/15:01:56

From: cgf AT bbc DOT com (Christopher Faylor)
Subject: Re: Process ID allocation methods
21 Mar 1998 15:01:56 -0800 :
Message-ID: <199803212251.RAA04336.cygnus.cygwin32.developers@hardy.bbc.com>
To: noer AT cygnus DOT com
Cc: cygwin32-developers AT cygnus DOT com

>Christopher Faylor wrote:
>[...]
>> I think that either of these schemes would be hard to do.  You'd
>> have to somehow instruct every running process to extend its shared
>> memory to include the new table(s).
>> 
>> Have there been complaints about the pids wrapping too fast or have people
>> been running out of pids?
>
>People have definitely been running out of pids.  I see the occasional
>"fork: no more processes" message in peoples' complaints to the list.
>The main thing I don't like about wrapping so soon is that no other
>Unix flavor that I know of does it this way.  I don't know enough
>about pids in Unix to know whether it violates any common assumptions
>people might make.  :-(

I've been watching pretty closely and I've never seen a "no more processes"
error that was actually the result of "no more processes".  EAGAIN gets
set in several places in fork.cc .  I think that every occurrence of
this error that I've seen on the mailing list has been a result of
some kind of incorrect initialization of the forked process rather than
someone actually running out of processes.

There was a discussion about pid creation on the linux developers list.
The consensus was that the only real assumption about pids that you
should make is:

	if ((pid = fork()) == 0)
	    exit(0);
	wait(0);
	if (fork() == pid)
	   fprintf(stderr, "this should never happen");

i.e., pids should not be reused rapidly.

This also illustrates the way pids are allocated on Digital UNIX:

    hardy:~> ps ax | grep "ps ax"
     4250 ttyq1    R  +     0:00.05 ps ax
     4251 ttyq1    S  +     0:00.02 grep ps ax
    hardy:~> ps ax | grep "ps ax"
     4254 ttyq1    R  +     0:00.05 ps ax
     4260 ttyq1    S  +     0:00.02 grep ps ax
    hardy:~> ps ax | grep "ps ax"
     3951 ttyq1    S  +     0:00.02 grep ps ax
     3970 ttyq1    R  +     0:00.14 ps ax
    hardy:~> ps ax | grep "ps ax"
     2251 ttyq1    R  +     0:00.05 ps ax
     4259 ttyq1    S  +     0:00.02 grep ps ax

As you can see, the pids vary in a very unpredictable way.

There are a lot of UNIXes out there that have a fixed number of processes
available.  I don't know if any are 128 or less but I just checked our
SCO system.  NPROC is set to 315 (?) there.
--
http://www.bbc.com/	cgf AT bbc DOT com			"Strange how unreal
VMS=>UNIX Solutions	Boston Business Computing	 the real can be."

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019