Path: utzoo!utgpu!watmath!att!pacbell!ames!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!piring.cwi.nl!jack From: jack@piring.cwi.nl (Jack Jansen) Newsgroups: comp.unix.wizards Subject: Re: Re^2: What kinds of things would you want in the GNU OS? Message-ID: <8318@boring.cwi.nl> Date: 8 Aug 89 08:53:14 GMT References: <160@uucs1.UUCP> <8311@boring.cwi.nl> <5568@ficc.uu.net> Sender: news@cwi.nl Organization: AMOEBA project, CWI, Amsterdam Lines: 48 In article <5568@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >[ gaf@uucs1.UUCP (gaf) wants an n-way wait() ] > >In article <8311@boring.cwi.nl>, guido@piring.cwi.nl (Guido van Rossum) writes: >> Sounds like you need multiple threads in a single address space, or >> light-weight threads as they are referred to in a discussion of the >> subject in neighboring newsgroups. I agree that they are *very* nice to >> have in an OS. > >An n-way wait can be implemented by using N threads, having each of them >waiting on a seperate event, and having a thread signal the mainline >when its event occurs. It can also be implemented using software interrupts... >(or in UNIX terms, signals). It's usually desirable, though, to implement >an n-way wait anyway, because it may be more efficient. Well, I've noticed that it is actually the other way around: everytime I use select() I really wanted multiple threads in the first place and only used select because they weren't there. Usually, my select code looks like while(1) { select() if( event-1 ) { handle-event-1; } if( event-2 ) { handle-event-2; } etc; } With multiple threads, you would have multiple threads each doing a simple while(1) { wait(); do-event; } Not only do I find this much easier to understand, but there are also other advantages, like having local state on the stack in stead of having a global array that you have to index by event number each time (think of things like handling two or more keyboards at the same time). -- -- Een volk dat voor tirannen zwicht | Oral: Jack Jansen zal meer dan lijf en goed verliezen | Internet: jack@cwi.nl dan dooft het licht | Uucp: mcvax!jack