From: Jean-Hugues ROBERT Date: 2002-04-22T17:01:38+09:00 Subject: Re: Threads creating threads creating threads... Hello, "About allocating C stacks for threads" At 11:50 22/04/2002 +0900, you wrote: >|Result was that the process's stack was fragmented into small chunks. >|Thread switching involved setjmp()/longjmp() only, no copying at all. Was >|much faster than native threads... but non-preemptive and not taking any >|advantages of multiprocessor architectures. > >Hmm, I thought this behavior requires the knowledge about internal of >jmp_buf structure. No intimate knowledge of structure of jmpbuf is necessary at all, it is truely 100% pure portable C code (C++ at the time). The only requirements is that longjmp() does not check that the jmpbuf is "deeper" (versus higher in stack as it should be normally). I had the issue with the Bull variant of AIX at the time. But I had no difficulties to find a fixed libc because apparently I was not the first to signal the issue (was 6/7 years ago I think). > I'm very interested in how it works. Could you >show me the source, please? > matz. Unfortunately I don't have the source code anymore, it belongs to one of my previous companies. Be prepared for a rather intense debugging session however, because when implementing that stack allocator you can not rely on the normal flow of control, you have to use a global state automata to know what to do next whenever you return from a setjmp()... I'll send further infos, if needed, privately (versus to mailing list) because I guess this is about very technical C stuff and not about Ruby so much ;-) Yours, Jean-Hugues --------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17