guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guile and ucontext


From: Fredrik Tolf
Subject: Re: Guile and ucontext
Date: Sat, 23 May 2009 15:00:03 +0200

On Sat, 2009-05-23 at 10:58 +0100, Neil Jerram wrote:
> Fredrik Tolf <address@hidden> writes:
> 
> >> >>From what I can tell from Guile's threads.c, Guile will just record the
> >> > top and bottom of a single stack per pthread, and since I'm switching
> >> > stack pointer between the original stack at the top of the process to
> >> > heap-allocated stacks, it would try to mark data words from almost the
> >> > entire process space when GC'ing.
> >> 
> >> I'm afraid I don't understand this.  Are you changing the whole stack
> >> of an existing thread?
> >
> > Well, yes. It is hard for me to think of how I would switch contexts
> > without switching stacks as well. :)
> 
> Sure, I understand that.  But I was struggling to understand what you
> said about "try to mark data words from almost the entire process
> space when GC'ing".  Guile knows the top and bottom of every stack
> that is in Guile mode, and marks from top..bottom of each stack; never
> from the top of one stack to the bottom of another one.  So I don't
> see how it could arise that Guile would try to mark almost the entire
> process space.  Can you explain that further?

Oh, I see. I thought it was weird. :)

Well, unless I have grossly misunderstood what I read in threads.[ch],
Guile records the base and top of the stack per POSIX thread, and
doesn't ever change the base unless it is found at a higher address than
before. Thus, to take an example:

Say that I first run a function in Guile mode when the stack pointer is
somewhere in the ELF-loader allocated stack; say at 0xBEEFBABE. Guile
records that address as the stack base. Then I switch to some
heap-allocated stack and run some Guile code. Now, my stack pointer
might be at, say, 0x0F00FACE. The previously recorded base address won't
change, but that stack will be used as the top of the stack. When the
Guile's GC runs, it would, then, try to mark all words from the stack
top to the stack base: that is, from 0x0F00FACE to 0xBEEFBABE.

Almost the entire process space, in other words (and probably with lots
of unmapped space in it).

I hope that makes my point clearer.

Fredrik Tolf






reply via email to

[Prev in Thread] Current Thread [Next in Thread]