From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds To: Lucio De Re Cc: 9fans@cse.psu.edu Subject: Re: [9fans] Re: Threads: Sewing badges of honor onto a Kernel In-Reply-To: <20040227093954.D22848@cackle.proxima.alt.za> Message-ID: References: <0374a3982e4b359e09ce2a3be9192f06@yourdomain.dom> <20040227093954.D22848@cackle.proxima.alt.za> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Thu, 26 Feb 2004 23:57:52 -0800 Topicbox-Message-UUID: fdb3f358-eacc-11e9-9e20-41e7f4b1d025 On Fri, 27 Feb 2004, Lucio De Re wrote: > > Is Torvalds really saying that environment[] is held _in_ the stack?! > No wonder he was reluctant to copy it! Specially when using "bash". > But I must be mistaken. Take a look if you don't believe me. There is a _lot_ of state on the stack. That's how C works. It's perfectly valid behaviour to do something like this: myfunction() { mytype myvariable; pthread_create(.. &myvariable); ... pthread_join(..); } where you give the thread you created its initial state on your own stack. You obviously must keep it there until the thread is done with it (either by waiting for the whole thread as in the above example, or by using some other synchronization mechanism), but the point is that C programmers are used to a fundamentally "flat" environment without segments etc. And what a private stack is, is _nothing_ more than a segment. And I have not _ever_ met a good C programmer that liked segments. So in a C/UNIX-like environment, private stacks are wrong. You could imagine _other_ environments where they might be valid, but even those other environments would not invalidate my points about efficiency and simplicity. Linus