Re: Sarge, kernel, threads and limits

2005-02-09 Thread Ian Wienand
On Tue, Feb 08, 2005 at 09:39:17AM +0100, Ryszard Lach wrote:
 * how to determine if my system/application is running linux or POSIX
   threads

Your system can be running both libraries at the same time,
depending on flags to the dynamic loader, etc.  The only sane way to
check is a runtime one

#include stdio.h
#include unistd.h
#include alloca.h
#include string.h

int isnptl (void)
{
size_t n = confstr (_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
if (n  0)
{
char *buf = alloca (n);
confstr (_CS_GNU_LIBPTHREAD_VERSION, buf, n);
if (strstr (buf, NPTL))
return 1;
}
return 0;
}

int main(void)
{
printf(NPTL: %s\n, isnptl() ? yes : no);
return 0;
}


 * how to determine limits of threads per system, threads per process and
   threads per user (hard compiled or set by PAM etc.)

I believe this is set by the ulimit of the number of processes.  This
can be changed by ulimit -u or in something like /etc/security/limits.conf
 
 * how is related amount of available stack to number of threads, which
   process can create

Did you mean : how is the amount of available system memory for stacks
related to the number of threads?  If you use the default stack size
that you get when you call pthread_create() you're going to run out of
memory pretty quickly.  If you change down with
pthread_attr_setstacksize() you're going to be able to run many more
threads.  However, you're still going to hit a kernel limit, see
kernel/fork.c:fork_init()

 /*
  * The default maximum number of threads is set to a safe
  * value: the thread structures can take up at most half
  * of memory.
  */
  max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);

 * I'd like also really understand what 'ps' displays. Don't say 'read
   manual', because manual assumes that you really know what's going on
   in kernel and tells you only how to display it.

ps should only display the main thread.  You need to pass something
like '-m' to show the sub-threads.

-i
[EMAIL PROTECTED]
http://www.gelato.unsw.edu.au


signature.asc
Description: Digital signature


Sarge, kernel, threads and limits

2005-02-08 Thread Ryszard Lach
Hi.

I've googled for a few days about it and I still have to say, that I'm a
little bit confused. Do you know any HOWTO or other document, which
could help me to understand what's going on in this area? Particulary,
I'd like to know:

* how to determine if my system/application is running linux or POSIX
  threads

* how to determine limits of threads per system, threads per process and
  threads per user (hard compiled or set by PAM etc.)

* how is related amount of available stack to number of threads, which
  process can create

* I'd like also really understand what 'ps' displays. Don't say 'read
  manual', because manual assumes that you really know what's going on
  in kernel and tells you only how to display it.

I suppose, that something in Sarge makes it not suitable for machines
with high loaded multithreaded processes (for example Apache 1.3 or
Tomcat). I'll probably will ask you additional questions, but first I'd
try to understend it well.

Best regards,

Richard.

-- 
First they ignore you. Then they laugh at you. Then they
fight you. Then you win. - Mohandas Gandhi.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]