Hi,
I am trying to reproduce Andreas' experiment [1] with Stack Cog. It
always ends up with crash during garbage collection.
Andreas' approach was to my understanding as follows:
1. Set a jmp_buf to to hold the jump target at the start of the
interpret() function
2. longjmp to this jmp_buf in the transferTo function if its argument
is 0 (thus exiting the interpreter once no processes are ready to
run).
3. in the wakeHighestPriority function do not terminate with error if
the list of ready to run processes is exhausted: just return 0 (which
goes to transferTo)
4. implement an external event loop in the hosting process polling for
events, entering the interpreter once any events are available.
My addition to this: heartbeat is no longer a separate thread: it is
invoked from either the lowest priority process (when
ioRelinquishProcessor is called) or right before entering the
interpreter from the external event loop if there are events.
Once I do-it in a running VM:
(ProcessorScheduler classPool at: #BackgroundProcess) terminate.
returns from the interpreter start occurring, transferTo is
periodically called with 0 argument, interpreter is not entered until
mouse is clicked etc.
But once garbage collection occurs, VM crashes on SEGV inside
markAndTrace. markAndTrace may be called with weird address like
30303030 (is this sort of magic number?)
If I disable GC completely, VM runs, responds to mouse clicks, I can
even open widgets but it crashes once memory exhausts.
How can process scheduler and GC conflict so terribly? What else am I missing?
Thanks for any ideas.
-------------------------------------
[1]
http://lists.squeakfoundation.org/pipermail/vm-dev/2009-November/003437.html--
Dimitry Golubovsky
Anywhere on the Web