From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@9fans.net Subject: Re: [9fans] Threading Model Questions From: "Russ Cox" Date: Tue, 20 May 2008 20:37:08 -0400 In-Reply-To: <052020081410.8330.4832DBDE0001F9A00000208A2206998499040196960E040E9F@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20080521004145.3B1D21E8C22@holo.morphisms.net> Topicbox-Message-UUID: abec86a0-ead3-11e9-9d60-3106f5b1d025 > 1) Are there any valid criticisms to this approach? Everyone seems to > agree it is superior to "lower-level" models, but are there any areas > where this model doesn't work comparatively well? People often ask how you would structure an operating system around communications primitives. Certainly the higher-level stuff can be done that way, but if you are multiplexing one cpu between running user code, running OS code, and handling driver interrupts, I don't see how to avoid locks. It might be that when we have 256-core processors, we'll just dedicate one core to device interrupts and then use channels to talk to that core. > 2) Are there examples of the equivalence between this model and other ones > (in terms of capability) I don't know what you mean by examples. The classic paper is Lauer and Needham, "On the Duality of Operating Systems Structures", 1978 (in Proc. Second International Symposium on Operating Systems) and 1979 (in Operating Systems Review). > 3) Why are the existing CSP-based libraries for other OS's (C++CSP2, > JCSP, pyCSP) much more complex? It seems like passing "channel ends" > instead of channels might be a good idea, but the rest of the stuff > seems like complexity with limited/no benefit? For example, defining > channels as One2One, One2Any, etc. Also, the idea of scoped forking > versus "free-form" thread/process creation. Perhaps it is premature optimization, or perhaps it is just complexity for complexity's sake. > 4) Finally, it looks like libthread has support for a lot of non-CSP > stuff. Is this part used much? Or is it just there for historical > and/or completeness reasons. Sometimes it is simply too tempting to resist a shared data structure, and then you need qlocks or reference counts or rsleep/rwakeup or some combination of the three. This is more common in libraries that are trying simply to be thread-safe without changing the interface to require kicking off a central server process for whatever the shared resource is. For example, the generic protocol mux library in Plan 9 from User Space is thread-safe and allows kicking off procs to handle protocol reads and writes, but it does not require them. Thus it must use qlocks internally. http://swtch.com/plan9port/man/man3/mux.html Russ