lkml.org 
[lkml]   [2003]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRE: Who changed /proc/<pid>/ in 2.6.0-test5-bk9?

On Tue, 7 Oct 2003, Robert White wrote:
>
> What is gained by having the independent file descriptor context that would
> be *broken* for lack of that independence?

You're coming at it from the wrong end. Sharing resources is inherently
bad. If there is no reason to share, you shouldn't share.

The reason people use threads is that sharing the VM space has real
advantages: it makes context switching much cheaper (fewer hw resources in
the form of TLB usages) and it allows for much faster synchronization
through a shared address space.

But the same isn't true of file descriptors or a lot of other software-
level abstractions. There are no inherent advantages to sharing, and in
fact sharing just gives more opportunity for race conditions, bad
interaction etc.

For example, one reason _not_ to share is that the subthread may want to
be as invisible to the "main thread" as possible. That's just good
programming practice - trying to isolate and encapsulate as much data as
possible.

The same way you shouldn't make all your variables global, you shouldn't
make all your data structures global unless you have a reason.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-11-18 23:46    [W:0.218 / U:1.148 seconds]
©2003-2014 Jasper Spaans. Advertise on this site