1. i am able to change stack using pthread_attr_setstacksize. when i try to set 1Gbyte stack size, then it is giving segment fault. why am i getting segment fault.
2. i have seen that i can generate upto 255 threads in a main routine. if i try to generate 256 threads, then it will show more than 256 thread some other figure(381). why it is showing more exact no of thread i am generating.
can i anyone help to clear why is it behaving like this?
is it possible to increase stack to 1G, if have enough RAM? if yes, how can i increase, as i am understanding, as thread is created inside process, so thread can have max process stack. it means, i need to increase process stack. how can i increase process stack? i am not familar with scarce resource.
I saw using /proc/(pid of process)/status, it shows, no of threads created under task. why it is not showing proper number of threads, when i go beyond 256 threads.
If you think you need 1G of stack in any context, you should realise you're headed down the wrong path. Remember, you can consider thread local storage for per thread data. Or a thread class will often provide an equivalent facility.
But just because you think you can aks for 1G of stack in any context, doesn't mean you should.
Just to add to Cubbi's point, in a 32 bit system you will get 4 GB of virtual address space in which child threads would be created. And if you increase the stack size for thread to 1 GB then beyond 4 GB of memory space for process will cause problem.
In 64 bit systems we can increase the datasegments and achieve more size in virtual space. In AIX we can increase upto 8 datasegments even though default data segment size is 2. I think it is not possible in 32 bit systems.