This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: continuation and multi-threading
- To: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Subject: Re: continuation and multi-threading
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 01 Aug 2000 22:08:45 +0200
- Cc: djurfeldt at nada dot kth dot se, guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <m3g0oqnjrp.fsf_-_@indy.STUDENT.CWRU.Edu><m3d7jxa9gv.fsf@indy.STUDENT.CWRU.Edu><p2tpunx85vu.fsf@bohne.zrz.tu-berlin.de><m33dksvk8i.fsf@indy.STUDENT.CWRU.Edu><200007311359.NAA00736@ruebe.zrz.tu-berlin.de><AD4WUXvScB@khim.sch57.msk.ru> <m3wvi2m0pw.fsf@indy.STUDENT.CWRU.Edu><87punux90c.fsf@piracy.red-bean.com><m3ya2h1vk4.fsf@indy.STUDENT.CWRU.Edu><873dkpwmw5.fsf@piracy.red-bean.com><m3vgxlo5db.fsf@indy.STUDENT.CWRU.Edu><xy73dkohlvy.fsf@mdj.nada.kth.se><m3ittkpxav.fsf@indy.STUDENT.CWRU.Edu>
- Reply-To: djurfeldt at nada dot kth dot se
Keisuke Nishida <kxn30@po.cwru.edu> writes:
> Okay, I got it. So a call of a continuation never returns, right?
Right.
> In that case, I can implement it this way:
>
> 1. When call-with-current-continuation is called, the VM copies
> the current stack and registers, and creates a continuation object
> with them.
>
> 2. The VM calls a closure with the continuation in the regular way.
>
> 3. If the closure finishes without calling the continuation,
> nothing happens. It continues execution.
>
> 4. Whenever a continuation is called, the VM throws out the current
> stack and recovers the stack and registers that the continuation has.
> It arranges the return value, and then continues execution.
>
> I think that's it. Since the VM clears the stack when a continuation
> is called, stack overflow won't happen. Is that right?
Well, it looks good to me, but then, I haven't studied your VM yet.
Also, in some VM designs, it is possible to do something which is more
efficient than stack copying.
I'll look at your VM as soon as I'm finished with the generic lexical
analyzer.
> If this works, I don't think I have to do anything special - just to
> implement a few additional VM instructions. Why do I need to break
> the stack into frame objects?
Don't ask me. :)
> One concern I have is the C stacks that people talk about. My VM does
> nothing with C functions.
Is your VM using a stack of its own? In that case, you might have to
take a copy of both stacks.
> I'll look at what Guile does now.
Good.