lua-users home
lua-l archive

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

On Fri, 2002-06-07 at 14:58, Jeff Petkau wrote:
> > Hmm, just out of curiosity, does anyone know how portable code like that
> > could be?  I've seen "fibers" used on x86/Linux and Windows, but what
> > about the other popular processors?  (*Arm, *Sparc, PPC, etc.).  My
> > stuff being geared mainly for games, portability to things like the
> > Gameboy Advance or PS2 or other game consoles would be nifty, too.
> Fibers work on pretty much any architecture; the requirements are
> the same as for setjmp()/longjmp() in C, which everyone supports.
> But on game consoles I think the stack space requirements really
> rule fibers out, since each fiber requires its own C stack.
> Coroutines at the scripting level are much more memory efficient.

Ah, I see.  Maybe in another year or two then when no console would show
it's face without 128/256MB of RAM... ~,^

Speaking of which, completely ot, but how much memory does the X-Box run
with... and is it feasible to use these fibers on it?  I would assume
so, given it's architecture...

> Also, I haven't looked at the Lua implementation, but I had
> assumed they were also more runtime efficient. In Stackless
> Python, switching to a coroutine is much faster than a function
> call, since the frame is already allocated and set up. I had
> hoped this was true in Lua also.

Hmm, in what I've worked on, a thread switch in the script engine could
be as fast as changing a pointer - all important data is stored in a
structure, not on the C stack, so simply point to a different "task"
structure and the byte-code loop will on the next iteration run the new
thread.  This is how I've implemented the call stack for
functions/methods, and likely what I'll do for the threads themselves in
the future.

> --Jeff