From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA24099; Sun, 6 Oct 2002 21:46:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA24153 for ; Sun, 6 Oct 2002 21:45:59 +0200 (MET DST) Received: from relay.pair.com (relay1.pair.com [209.68.1.20]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g96Jjw525185 for ; Sun, 6 Oct 2002 21:45:58 +0200 (MET DST) Received: (qmail 94521 invoked from network); 6 Oct 2002 19:45:56 -0000 Received: from adsl-host-sf-228.apexworld.net (HELO checkerlap.d6.com) (66.114.212.228) by relay1.pair.com with SMTP; 6 Oct 2002 19:45:56 -0000 X-pair-Authenticated: 66.114.212.228 Message-Id: <4.3.2.7.2.20021006123226.018aa758@mail.d6.com> X-Sender: checker@mail.d6.com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Sun, 06 Oct 2002 12:46:06 -0700 To: Jerome Vouillon From: Chris Hecker Subject: Re: [Caml-list] Coroutines Cc: caml-list@inria.fr In-Reply-To: <20021006181345.GA23808@strontium.pps.jussieu.fr> References: <4.3.2.7.2.20021004000748.030bd2c0@mail.d6.com> <4.3.2.7.2.20021004000748.030bd2c0@mail.d6.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >I just spent a few hours implementing a small coroutine library. It >is fully written in Ocaml. Below is a quick description. Would it >satisfy your needs ? I can send you a copy, or make it available on the >Web if you like. Ah, it looks like your library is done with cps. The problem is, how would you yield in the middle of a for-loop or something? I assume the answer is "don't do that" :), which is valid, but a bit frustrating if you just want to turn any bit of code into a fiber and be able to yield anywhere it's convenient. On the upside, you can do yours in vanilla caml. Definitely post your library on the web, I'd be interested in seeing it. Thanks! I realized after I sent my post about the stack that I can easily prototype my Fiber library with Threads. I'll call what I want Fibers to differentiate them from Coroutines where there's value passing a la Knuth, and to imply that Fibers are imperative in nature. I can make a thread per fiber, and then have a mutex per thread, and have my yield/switch calls do the right mutex silliness to make the threads behave cooperatively rather than preemptively. This is a bit heavyweight for what I want in the systhreads case (I'd like Fibers to be very lightweight and cheap, since they don't need any os machinery, just a quick context load), but it will allow a fully functional (er, operational :) prototype so I can see if this is what I really want. I could ease a bit of the efficiency concerns by adding a thread api for turning off the tick thread in the case where no "real" threads are created, since mine will never be able to be preempted anyway so setting young_limit and the signal is just a waste of time. Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners