DragonFly users List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
threads, linux and dragonfly
/* compile with: gcc -pthread -o thread-limit thread-limit.c */
/* originally from: http://www.volano.com/linuxnotes.html */
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#define MAX_THREADS 50000
int i;
void run(void) {
char c;
if (i < 10)
printf("Address of c = %u KB\n", (unsigned int) &c / 1024);
sleep(60 * 60);
}
int main(int argc, char *argv[]) {
int rc = 0;
pthread_t thread[MAX_THREADS];
printf("Creating threads ...\n");
for (i = 0; i < MAX_THREADS && rc == 0; i++) {
rc = pthread_create(&(thread[i]), NULL, (void *) &run, NULL);
if (rc == 0) {
pthread_detach(thread[i]);
if ((i + 1) % 100 == 0)
printf("%i threads so far ...\n", i + 1);
}
else
printf("Failed with return code %i creating thread %i.\n",
rc, i + 1);
}
exit(0);
}
my dragonfly box
================
head# gcc -pthread -o thread-limit thread-limit.c
head# ./thread-limit
35300 threads so far ...
35400 threads so far ...
35500 threads so far ...
35600 threads so far ...
35700 threads so far ...
35800 threads so far ...
35900 threads so far ...
36000 threads so far ...
36100 threads so far ...
36200 threads so far ...
36300 threads so far ...
36400 threads so far ...
36500 threads so far ...
Failed with return code 35 creating thread 36529.
linux box
===========
$ ./thread-limit
Creating threads ...
-- cut --
100 threads so far ...
200 threads so far ...
300 threads so far ...
400 threads so far ...
500 threads so far ...
600 threads so far ...
700 threads so far ...
800 threads so far ...
900 threads so far ...
1000 threads so far ...
1100 threads so far ...
1200 threads so far ...
1300 threads so far ...
1400 threads so far ...
1500 threads so far ...
Failed with return code 11 creating thread 1533.
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]