All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lawrence Bowie <ldb@ldb-jab.org>
To: Mikado <mikado4vn@yahoo.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Problem with Native POSIX Thread Library
Date: Sun, 16 Oct 2005 09:49:09 -0400	[thread overview]
Message-ID: <43525A55.5010703@ldb-jab.org> (raw)
In-Reply-To: <20051016105800.2454.qmail@web53712.mail.yahoo.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

These modifications below might shed some light on your issue.

LDB

- ------------------- CODE ---------------------------
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>

#define MAX 10000

void print_msg(void * msg);
int main(void);

void print_msg(void * arg)
{
    pthread_detach(pthread_self());
    sleep(10);
    pthread_exit(NULL);
}

int main(void)
{
    pthread_t thread_id[MAX];
    int i, ret, err;

    for (i = 0; i < MAX; i++)
    {
          ret = pthread_create(&thread_id[i], NULL, (void *)&print_msg,
(void *)0);

          if (ret) {
              err = errno;
              printf("Error creating thread %d: %s\n", i,strerror(err));
          }
     }

    pthread_exit(NULL);
}
- ----------------------- CODE -------------------------------

Mikado wrote:
> Hi all,
> 
> I'm using 2.6 kernel with NPTL support in kernel and libc but I cannot create more than 400
> threads with NPTL. In the past, I used 2.4 kernel and I can create about 1500 threads. I dont want
> to use traditional LinuxThread because I dont like the way it pthread_detach() (it "clone"s too
> many processes). Reading some documents about NPTL, I thought it can creates many threads but it's
> not true in my case. I need somebody's help. Thanks in adv.
> 
> System info:
> - Kernel: 2.6.13.4
> - RAM: 256 + 128
> - CPU: PentiumIII 937.939MHz
> 
> My code is below:
> 
> ===== CODE =====
> #include <stdio.h>
> #include <unistd.h>
> #include <pthread.h>
> 
> #define MAX 10000
> 
> void print_msg(void * msg);
> int main(void);
> 
> void print_msg(void * arg)
> {
>         pthread_detach(pthread_self());
>         sleep(10);
>         pthread_exit(NULL);
> }
> 
> int main(void)
> {
>         pthread_t thread_id[MAX];
>         int i, ret;
> 
>         for (i = 0; i < MAX; i++)
>         {
>                 ret = pthread_create(&thread_id[i], NULL, (void *)&print_msg, (void *)0);
>                 if (ret)
>                         printf("Error creating thread %d\n", i);
>         }
> 
>         pthread_exit(NULL);
> }
> ===== CODE =====
> 
> 
> 
> 		
> __________________________________ 
> Start your day with Yahoo! - Make it your home page! 
> http://www.yahoo.com/r/hs
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFDUlpVXk+Xn2ZNlsQRAohvAJsGJzArWNoqVIgxOM3eotvqzZW6DQCfcNWj
XwulOScx1yPWEtN5ZXHgmLU=
=Yl1x
-----END PGP SIGNATURE-----

      parent reply	other threads:[~2005-10-16 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-16 10:58 Problem with Native POSIX Thread Library Mikado
2005-10-16 13:43 ` Lawrence Bowie
2005-10-16 17:53   ` Mikado
2005-10-16 19:07     ` Markus Rechberger
2005-10-17  4:09       ` Mikado
2005-10-17  8:19         ` Markus Rechberger
2005-10-16 13:49 ` Lawrence Bowie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43525A55.5010703@ldb-jab.org \
    --to=ldb@ldb-jab.org \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=mikado4vn@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.