Hey folks,

I was playing with doing a Finite State Machine (FSM) for Factor's GC
the other day.  I got a very simple little test harness working so I
could play with the idea.  The crazy part however is that I use cpp
macros to generate the FSM:

http://paste.factorcode.org/responder/pastebin/show-paste?n=57

This isn't an actual functioning GC, just a tester to work out the FSM
transitions and such.

You can play with it like this:

1) save the gen.h part and the fsm_gc.c parts to separate files.
2) make fsm_gc
3) ./fsm_gc
4) Type various letters to play with it.  x will exit.

The harness just takes letters and feeds those as events to the GC
printing out lots of information on how it transitions and what it
does.  You can use 'a' to allocate ram, then 'c' to compact it, 's' to
tell it things are slack, 't' for tight, 'g' to grow it up, and so on.

What I'll be doing next is "porting" the Factor GC to use this and see
if that makes things simpler.

One key thing to notice is that it keeps the state in a GCState struct,
which could replace the global variables and other nuances of the
current Factor GC.  This would be a good first step toward a thread
safe Factor and make it more embeddable.

Well, comments welcome.

-- 
Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to