caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: Jerome Vouillon <vouillon@pps.jussieu.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Coroutines
Date: Sun, 06 Oct 2002 12:46:06 -0700	[thread overview]
Message-ID: <4.3.2.7.2.20021006123226.018aa758@mail.d6.com> (raw)
In-Reply-To: <20021006181345.GA23808@strontium.pps.jussieu.fr>


>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


  reply	other threads:[~2002-10-06 19:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-04 10:25 [Caml-list] gc question: thread stacks, fibers, etc Chris Hecker
2002-10-06 18:13 ` [Caml-list] Coroutines Jerome Vouillon
2002-10-06 19:46   ` Chris Hecker [this message]
2002-10-12 15:58   ` John Max Skaller
2002-10-12 16:33 ` [Caml-list] gc question: thread stacks, fibers, etc John Max Skaller
2002-10-12 18:54   ` Chris Hecker
2002-10-13  8:32 ` Xavier Leroy
2002-10-14  7:18   ` Chris Hecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4.3.2.7.2.20021006123226.018aa758@mail.d6.com \
    --to=checker@d6.com \
    --cc=caml-list@inria.fr \
    --cc=vouillon@pps.jussieu.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).