Multithreaded program in C: calculating thread stack space
- by SlappyTheFish
Situation:
I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created.
Each thread forks - the child runs a PHP process via exec() and the parent waits for it to finish.
Each PHP process takes the next item from a queue, processes it and exits.
Basic code: http://www.4pmp.com/2010/03/multitasking-php-in-parallel/
Problem:
The PHP processes are Symfony tasks and Symfony requires a fairly huge amount of memory. How can I safely calculate the required stack space for each thread so that PHP processes will have enough memory?
The memory limit set in php.ini is 128Mb so should I allocate this much space in the stack?