My c progam is not able to create more than 8 threads
. It returns the error code EAGAIN(11)
. Which is for lack of resources available. Before posting this question I googled for its solution but could not get much out of that. Here are the detail I have found for my program and unix system.
My thread creation functions is :-
thread_initialise(File *CFG_FILE)
{
int total_pthreads; //reads number of threads I want for the program from configuration file.
int rc =0 ;
for (i = 0; i < total_pthreads; i++)
{
rc = pthread_create (&pthread_list[i], NULL, (fp)(begin_worker_pthread), NULL);
if (rc !=0) printf("Thread creation Error Code: %d",rc);
}
}
Memory consumed by my program while execution is: pmap -x <pid> = 1111844
Unix Version:uname -a = Linux 2.6.18-308.24.1.el5 #1 SMP Wed Nov 21 11:42:14 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
Thread Max value in unix cat /proc/sys/kernel/threads-max = 81920
ulimit -u max user processes (-u) 16000
ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 40960
max locked memory (kbytes, -l) 3000000
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 5857280
real-time priority (-r) 0
stack size (kbytes, -s) 512000
cpu time (seconds, -t) unlimited
max user processes (-u) 16000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Please help how the maximum number of threads is calculated/ fixed by my system. I want to increase my threads to 32
.