UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-02-20 10:13 AM

rakeshcs123
Guest

Re: Finding max thread per process

Hi All,
I have to make the resource checking. which include finding the maximum number of threads per process in the unix platforms. can you please help in understanding how to get the maximum number of thread per process on the major unix platform.
I know for HPUX ($/usr/sbin/kmtune | grep  max_thread_proc)
but need to know for the rest of the platforms like (Solaris, AIX, Linux, MAC OSX)
I am sure there will be some command to get these details. please help me.

Thanks in advance...

#2 2008-02-20 10:32 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,200

Re: Finding max thread per process

As far as I know, there is no per process limit of the number of threads in Linux, only a per user limit set with ulimit -u. I expect the same is true for most other systems.

Offline

#3 2008-02-20 10:54 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Finding max thread per process

The 'generic' method aka POSIX is via:

http://www.cognitus.net/html/howto/pthr … .html#s4_6

If you don't want to follow the link.. then its the value returned from the call sysconf( _SC_THREAD_THREADS_MAX ) ... where a -1 mean technically unlimited ( otherwise known - usually - as lazy kernel programmers )...

If you get a -1 then you must calculate the standard stack size per thread and apply that against the total memory ( including swap ) on the system...

It can get much more complicated than that... but i3839 made me drink tonight so I cannot remember the rest of the answer...

Bad i3839... bad bad bad... !!!


Michael


P.S. Ok - I had to blame SOMEONE and you were the only one online darn it !


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#4 2008-02-20 10:57 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Finding max thread per process

Oh... and thats not 'per process'... technically its total thread count... but that count ( impls ) seems to be confused...

Either way - its a good starting point...

Must sleep now... nite... :)


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#5 2008-02-20 11:21 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,200

Re: Finding max thread per process

But _SC_THREAD_THREADS_MAX  gives the theoretical limit for a theoretical
system, if it doesn't return -1 as it does here, so it's totally useless.

I though he was interested in artificial limits anyway, like ulimit -u.

Of course the number of threads per process is limited by the amount of virtual
memory available, but that's true for everything that uses memory...

Offline

#6 2008-02-20 09:04 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Finding max thread per process

Back home... sober now... which makes me very sad but anyway...

Yeah...

The use of sysconf does actually work as expected on a lot of systems like HPUX / Solaris / AIX i.e. it returns a real value instead of the bogus -1 / unlimited value...

BUT... its the programmatic / in application way of retrieving the value... as opposed to ulimit and ilk that are used as command line utilities...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#7 2009-08-18 07:17 PM

6205433169281
Guest

Re: Finding max thread per process

Board footer

Powered by FluxBB