Quote:
As for figuring out how much stack space is needed, is there a way I can reasonably figure out what's needed by the rest of that stuff? I gave it the extra 100 as a fudge factor, but it sounds like that wasn't enough fudge...
You would have to do some serious profiling. Valgrind should help with this and there are other tools, I just don't know what they are. I think you may be pre-optimizing. Use the default stack size, and see how many threads you can spin up. You may be able to get enough going and still test your deadlock cases without all this crazy stack size manipulation. If that's insufficient, just overengineer. Take what you think you need and multiply it by 10. That will probably be enough, and still be significantly smaller than your default. If it's still too much, whittle it down until you get the smallest number you can without seg faulting. But be warned, that's a crude method. You would have to test every possible execution path to make sure you wont seg fault from a too-small stack. It should be a very last resort.