From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds To: dbailey27@ameritech.net Cc: 9fans@cse.psu.edu Subject: Re: [9fans] Re: Threads: Sewing badges of honor onto a Kernel In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Fri, 27 Feb 2004 00:08:38 -0800 Topicbox-Message-UUID: fdc9f70c-eacc-11e9-9e20-41e7f4b1d025 On Fri, 27 Feb 2004 dbailey27@ameritech.net wrote: > > > The rationale is that it's incredibly more sane, and it's the logical > > place to put something that (a) needs to be allocated thread-specific and > > (b) doesn't need any special allocator. > > You've just proven my point. Thread specific. Being Thread specific, it > is data that is reserved to the scope of a single thread. Nothing more. > If you want more scope there are many more usages of memory that > are better utilized. NO! A "per-thread allocation" does NOT MEAN that other threads should not access it. It measn that the ALLOCATION is thread-private, not that the USE is thread-private. per-thread allocations are quite common, and critical. If you have global state, you need to protect them with locks, and you need to have nasty global allocators. One common per-thread allocation is the "I want to wait for an event". The data is clearly for that one thread, and using a global allocator would be WRONG. Not to mention inefficient. But once the data has been allocated, other threads are what will actually use the data to wake the original thread up. So while it wants a per-thread allocator, it simply wouldn't _work_ if other threads couldn't access the data. That's what a "completion structure" is in the kernel. It's all the data necessary to let a thread wait for something to complete. Another thread will do "complete(xxx)", where "xxx" is that per-thread data. You don't like it. Fine. I don't care. You're myopic, and have an agenda to push, so you want to tell others that "you can't do that, it's against my agenda". While I'm telling you that people _do_ do that, and that it makes sense, and if you didn't have blinders on, you'd see that. Linus