This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Process limit in CYGWIN?


On Dec  3 20:49, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin wrote:
> Hi all,
> 
> I have some test code that forks number of processes, and it looks
> like under Cygwin it fails at fork number 255 (plus minus one).
> 
> There is no getrlimit()'s RLIMIT_NPROC on Cygwin (unlike Unices) yet I
> see that my shell somehow shows the process limit of 256: $ ulimit -u
> 256

IDK what bash is showing there, because RLIMIT_NPROC is undefined
on Cygwin.

> I tried to look it up, but nothing useful comes up, so decided to ask
> the list -- it can be a lot quicker...
> 
> 1. Is there a limit, indeed?

Yes, there is.

> 2. If there is, is it a documented feature?

No, it isn't.  Not that I'm aware of.  It's not exactly a feature, just
an artificial limitation, see below.

> 3. Can it be found out programmatically?  (IDK how bash does it, since
> like I mentioned, RLIMIT_NPROC is nonexistent,

RLIMIT_NPROC is different.  RLIMIT_NPROC is the maximum number of
threads / processes for the current user.  There's no known limit of
processes in Windows, but the number of threads per process is limited
to 1023 or 1024, not sure exactly.  There's no satisfactory mapping to
an RLIMIT_NPROC value.

The limit in Cygwin is quite different.  It's a hardcoded limit of 256
concurrent Cygwin child processes for a single parent process (no such
limit for child processes spawned using native Windows means).  The
reason is a static array holding process info for all children.

See winsup/cygwin/sigproc.cc, line 47ff.

> 4. Can the limit be changed (dynamically or compile time)?

It's hardcoded, so, no.  There's no *simple* way to change that other
than raising the size of that array generally (which I'd hate to do for
32 bit Cygwin).  The more sophisticated change would be to allocate the
array dynamically or even to convert this to a single or doubly linked
list.  We could store the info in the cygheap.  But that's quite a bit
of work and I'm rather limited in time ATM.  I'm very open to patches in
this regard, though...


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]