Page 2 of 2

Re:#define MAX_THREADS ... ?

Posted: Sun Jul 02, 2006 12:49 pm
by Candy
Guest wrote: I'ld recommend what solar told you.
For examples bsd* uses a sysctl() to set & get this value
Linux also uses the same, but for threads & process linux doesn't have a maximum limit, the max limit is your memory.
Thanks
A limit is defined as, if all other is unlimited, what would this maximum be.

Linux has a 16 bit pid. They cannot create more than 65535 processes in any case, ever. AFAIK each thread also uses a pid, so that would limit the number of threads to 65535 as well.

Re:#define MAX_THREADS ... ?

Posted: Sun Jul 02, 2006 1:23 pm
by FlashBurn
I have the following limits and I think they are enough (i also like only to learn from my os, because when I have a 64bit machine I will rewrite it for 64bit and then there wont be such limits).

Code: Select all

4096 processes
65536 threads
65536 ports

Re:#define MAX_THREADS ... ?

Posted: Sun Jul 02, 2006 1:26 pm
by Pype.Clicker
indeed, linux uses the PID for threads identification, and yes, it would be typical to use a "factory" pattern in those cases. And yes, using 16 bits as PID is very convenient for the OS designer as it means a flat table of process pointers can safely be envisionned (yes, we're locking 256 KB for the process table, sue us).

yet, iirc, there are patches that allow 32-bit pids, right ?

Code: Select all

// out of linux/threads.h ...
/*
 * This controls the default maximum pid allocated to a process
 */
#define PID_MAX_DEFAULT 0x8000

/*
 * A maximum of 4 million PIDs should be enough for a while:
 */
#define PID_MAX_LIMIT (sizeof(long) > 4 ? 4*1024*1024 : PID_MAX_DEFAULT)