Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
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.
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).
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 ?
// 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)