On Sun, Jul 13, 2003, Damon Hastings wrote: > [...] > So it copies the old stack out and the new stack in during every context > switch? I don't know much about thread implementation, but I guess I > thought you could just swap out the stack pointer instead of copying the > whole stack. > [...]
Sure, Pth just swaps the stack pointer, of course. Nevertheless what here was mentioned is the fact that each stack consumes memory. If you have a large number of threads in your system, just the allocated stacks already accumulate to a rather large memory consumption. > It's good that you guys tell me these things during the > planning stage -- I guess that's an argument for using heap allocation > instead of stack allocation, eh? In Pth only the (original) stack of the main thread is auto-growing (done by the OS), while the other stacks are fixed size stacks. If you don't have very high recursion levels or other functions uses large buffers on the stack, this is no problem. But if you require really lots of stack space, you should be careful or at least spawn the Pth threads with a larger stack size. Ralf S. Engelschall [EMAIL PROTECTED] www.engelschall.com ______________________________________________________________________ GNU Portable Threads (Pth) http://www.gnu.org/software/pth/ Development Site http://www.ossp.org/pkg/lib/pth/ Distribution Files ftp://ftp.gnu.org/gnu/pth/ Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/ User Support Mailing List [EMAIL PROTECTED] Automated List Manager (Majordomo) [EMAIL PROTECTED]