* Problem with Native POSIX Thread Library
@ 2005-10-16 10:58 Mikado
2005-10-16 13:43 ` Lawrence Bowie
2005-10-16 13:49 ` Lawrence Bowie
0 siblings, 2 replies; 7+ messages in thread
From: Mikado @ 2005-10-16 10:58 UTC (permalink / raw)
To: linux-c-programming
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
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Problem with Native POSIX Thread Library 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 13:49 ` Lawrence Bowie 1 sibling, 1 reply; 7+ messages in thread From: Lawrence Bowie @ 2005-10-16 13:43 UTC (permalink / raw) To: Mikado; +Cc: linux-c-programming 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 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problem with Native POSIX Thread Library 2005-10-16 13:43 ` Lawrence Bowie @ 2005-10-16 17:53 ` Mikado 2005-10-16 19:07 ` Markus Rechberger 0 siblings, 1 reply; 7+ messages in thread From: Mikado @ 2005-10-16 17:53 UTC (permalink / raw) To: Lawrence Bowie; +Cc: linux-c-programming Thank Lawrence, I've got this error message: Error creating thread 382: Cannot allocate memory Error creating thread 383: Cannot allocate memory Error creating thread 384: Cannot allocate memory Error creating thread 385: Cannot allocate memory Error creating thread 386: Cannot allocate memory Error creating thread 387: Cannot allocate memory ................ It always begins at thread 382. My RAM is 256+128 MB, isn't it enough???? hm... still in trouble now. --- Lawrence Bowie <thesource@ldb-jab.org> wrote: > 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 > > > - > 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 > __________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problem with Native POSIX Thread Library 2005-10-16 17:53 ` Mikado @ 2005-10-16 19:07 ` Markus Rechberger 2005-10-17 4:09 ` Mikado 0 siblings, 1 reply; 7+ messages in thread From: Markus Rechberger @ 2005-10-16 19:07 UTC (permalink / raw) Cc: Lawrence Bowie, linux-c-programming Hi, check your ulimits $ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) unlimited virtual memory (kbytes, -v) unlimited lower the stack size and try again (read on more about it if you set it to low globally you could get into trouble with your system) Markus On 10/16/05, Mikado <mikado4vn@yahoo.com> wrote: > Thank Lawrence, I've got this error message: > > Error creating thread 382: Cannot allocate memory > Error creating thread 383: Cannot allocate memory > Error creating thread 384: Cannot allocate memory > Error creating thread 385: Cannot allocate memory > Error creating thread 386: Cannot allocate memory > Error creating thread 387: Cannot allocate memory > ................ > > It always begins at thread 382. My RAM is 256+128 MB, isn't it enough???? hm... still in trouble > now. > > > --- Lawrence Bowie <thesource@ldb-jab.org> wrote: > > > 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 > > > > > - > > 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 > > > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > - > 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 > -- Markus Rechberger ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problem with Native POSIX Thread Library 2005-10-16 19:07 ` Markus Rechberger @ 2005-10-17 4:09 ` Mikado 2005-10-17 8:19 ` Markus Rechberger 0 siblings, 1 reply; 7+ messages in thread From: Mikado @ 2005-10-17 4:09 UTC (permalink / raw) To: Markus Rechberger; +Cc: Lawrence Bowie, linux-c-programming Hi thank you, Markus I decreased my stack size limit to 512k then it's ok, it now can creates about 6000 threads then it gets errors: Error creating thread 6067: Resource temporarily unavailable Error creating thread 6068: Resource temporarily unavailable Error creating thread 6069: Resource temporarily unavailable Error creating thread 6070: Resource temporarily unavailable .... But i'm wondering if there is a way to make it better. Maybe this problem happens 'cause of my small RAM size. --- Markus Rechberger <mrechberger@gmail.com> wrote: > Hi, > > check your ulimits > > $ ulimit -a > core file size (blocks, -c) 0 > data seg size (kbytes, -d) unlimited > file size (blocks, -f) unlimited > max locked memory (kbytes, -l) unlimited > max memory size (kbytes, -m) unlimited > open files (-n) 1024 > pipe size (512 bytes, -p) 8 > stack size (kbytes, -s) 8192 > cpu time (seconds, -t) unlimited > max user processes (-u) unlimited > virtual memory (kbytes, -v) unlimited > > lower the stack size and try again (read on more about it if you set > it to low globally you could get into trouble with your system) > > Markus > > On 10/16/05, Mikado <mikado4vn@yahoo.com> wrote: > > Thank Lawrence, I've got this error message: > > > > Error creating thread 382: Cannot allocate memory > > Error creating thread 383: Cannot allocate memory > > Error creating thread 384: Cannot allocate memory > > Error creating thread 385: Cannot allocate memory > > Error creating thread 386: Cannot allocate memory > > Error creating thread 387: Cannot allocate memory > > ................ > > > > It always begins at thread 382. My RAM is 256+128 MB, isn't it enough???? hm... still in > trouble > > now. > > > > > > --- Lawrence Bowie <thesource@ldb-jab.org> wrote: > > > > > 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 > > > > > > > - > > > 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 > > > > > > > > > > > > > __________________________________ > > Yahoo! Music Unlimited > > Access over 1 million songs. Try it free. > > http://music.yahoo.com/unlimited/ > > - > > 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 > > > > > -- > Markus Rechberger > - > 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 > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problem with Native POSIX Thread Library 2005-10-17 4:09 ` Mikado @ 2005-10-17 8:19 ` Markus Rechberger 0 siblings, 0 replies; 7+ messages in thread From: Markus Rechberger @ 2005-10-17 8:19 UTC (permalink / raw) To: Mikado; +Cc: Lawrence Bowie, linux-c-programming I changed it in /etc/security/limits.conf to get mysql work (you can set this up per user), also check if PAM is set up correctly. check out http://nptl.bullopensource.org/Tests/NPTL-limits.html "When you require the minimum stacksize (64Kb) with >>pthread_attr_setstacksize()<<, you can create up to 262000 threads before the stack becomes the limitation." maybe this helps I haven't tried it though Markus On 10/17/05, Mikado <mikado4vn@yahoo.com> wrote: > Hi thank you, Markus > > I decreased my stack size limit to 512k then it's ok, it now can creates about 6000 threads then > it gets errors: > > Error creating thread 6067: Resource temporarily unavailable > Error creating thread 6068: Resource temporarily unavailable > Error creating thread 6069: Resource temporarily unavailable > Error creating thread 6070: Resource temporarily unavailable > .... > > But i'm wondering if there is a way to make it better. Maybe this problem happens 'cause of my > small RAM size. > > --- Markus Rechberger <mrechberger@gmail.com> wrote: > > > Hi, > > > > check your ulimits > > > > $ ulimit -a > > core file size (blocks, -c) 0 > > data seg size (kbytes, -d) unlimited > > file size (blocks, -f) unlimited > > max locked memory (kbytes, -l) unlimited > > max memory size (kbytes, -m) unlimited > > open files (-n) 1024 > > pipe size (512 bytes, -p) 8 > > stack size (kbytes, -s) 8192 > > cpu time (seconds, -t) unlimited > > max user processes (-u) unlimited > > virtual memory (kbytes, -v) unlimited > > > > lower the stack size and try again (read on more about it if you set > > it to low globally you could get into trouble with your system) > > > > Markus > > > > On 10/16/05, Mikado <mikado4vn@yahoo.com> wrote: > > > Thank Lawrence, I've got this error message: > > > > > > Error creating thread 382: Cannot allocate memory > > > Error creating thread 383: Cannot allocate memory > > > Error creating thread 384: Cannot allocate memory > > > Error creating thread 385: Cannot allocate memory > > > Error creating thread 386: Cannot allocate memory > > > Error creating thread 387: Cannot allocate memory > > > ................ > > > > > > It always begins at thread 382. My RAM is 256+128 MB, isn't it enough???? hm... still in > > trouble > > > now. > > > > > > > > > --- Lawrence Bowie <thesource@ldb-jab.org> wrote: > > > > > > > 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 > > > > > > > > > - > > > > 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 > > > > > > > > > > > > > > > > > > > __________________________________ > > > Yahoo! Music Unlimited > > > Access over 1 million songs. Try it free. > > > http://music.yahoo.com/unlimited/ > > > - > > > 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 > > > > > > > > > -- > > Markus Rechberger > > - > > 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 > > > > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors' Choice 2005 > http://mail.yahoo.com > -- Markus Rechberger ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problem with Native POSIX Thread Library 2005-10-16 10:58 Problem with Native POSIX Thread Library Mikado 2005-10-16 13:43 ` Lawrence Bowie @ 2005-10-16 13:49 ` Lawrence Bowie 1 sibling, 0 replies; 7+ messages in thread From: Lawrence Bowie @ 2005-10-16 13:49 UTC (permalink / raw) To: Mikado; +Cc: linux-c-programming -----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----- ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-17 8:19 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).