[Mono-devel-list] Embedding Mono in a Virtual World

Jim Purbrick jimpurbrick at yahoo.co.uk
Wed Feb 9 13:06:32 EST 2005


 --- Paolo Molaro <lupus at ximian.com> wrote: 
> > I need to restart the scripts transparently, as if
> > they were running in a thread or fiber. 
> > Currently each running script has a stack, 
> > heap and registers which are saved when 
> > another script is scheduled.
> 
> I think you have two options:
> *) inject code into the scripts to make them state
> machines
> that will periodically check the timeout info and
> save the state to 
> an object and reload it when it's restarted, similar
> to how the C#
> compiler handles the yield construct.

I've started trying this approach out using yields and
think it might well work, although with yields strange
things happen mixing them with recursion. I'm not sure
how generally a call graph can be mapped to a state
machine, especially in the presence of recursion.

The easiest way to represent the information would be
to build a stack for each script, but could I mess
with the stack pointer to switch stacks or would I
have to emulate a stack using heaps and would that be
horribly inefficient?

I keep coming back to the idea that what I really want
is a light weight user threads library. I've seen some
stuff about people using Win32 fibers to run managed
code. Would it be possible to use a Linux light weight
threads library in a similar way?

A final alternative would be to change the way the
runtime handles threads to use light weight threads,
but this seems even more work than trying to emulate
threads in bytecode.

Just wanted to get your thoughts on these options
before I got heavily in to implementing the state
machine option.

> *) use the threadpool as initially suggested: you
> will queue all the scripts for execution.

I looked at this approach and implemented a simple
test app which used Abort and ResetAbort to cancel
processing after some timeout. While this would stop
DOS attacks it would also cancel arbitrarily long
valid processing, which is not the current model and
so not acceptable.

Cheers,

Jim.


	
	
		
___________________________________________________________ 
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com



More information about the Mono-devel-list mailing list