[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: AW: Fiber thing?
- From: "Michael Flad" <MichaelFlad@...>
- Date: Sat, 8 Jun 2002 17:41:30 +0200
for something similar implemented with very few asm code
one can have a look at the Microthreads section from
Bruce Dawson in the book Game Programming Gems 2.
Claw Design Software http://www.clawdesign.com
Ludwigstr. 8 D-72474 Winterlingen / Germany
Tel: +49 7434 3931 Fax: --- ICQ: 48525570
> -----Ursprüngliche Nachricht-----
> Von: email@example.com
> [mailto:firstname.lastname@example.org]Im Auftrag von Sean Middleditch
> Gesendet: Samstag, 8. Juni 2002 16:31
> An: Multiple recipients of list
> Betreff: Re: Fiber thing?
> Fibers are fairly simple. Basically, when a single OS thread is
> running, you have your registers and code stack. Say you are in the
> middle of some Lua code, which was called from a C function, which was
> invoked from some other Lua code. If the Lua interpreter decides to
> switch Lua threads, it can't be easily done, because of that C function
> on the call stack.
> With fibers, you'd do something like this. Each function stack you got
> into (Lua call stack), you'd get to a point where you decide to swap
> fibers. Basically, this code would copy the stack and registers to a
> buffer (or, depending on implementation and needed stack size, leave it
> where it is), push the intruction pointer, swap the stack pointer, and
> pop the instruction pointer, pull out the new buffer's stack/data, and
> pop the instruction pointer again. You'll have just popped the
> instruction pointer from the new stack, and thus your new thread will be
> I'm not too great at explaining these, especially given that I've never
> used them myself and thus don't have any code to use as an example. You
> need to look at from the CPU's perspective, tho, not the OS - the OS has
> nothing to do with the fibers.