Re: [gst-devel] Re: RFC: GNOME 2.0 Multimedia strategy



On Sat, May 19, 2001 at 05:34:27PM -0700, Erik Walthinsen wrote:
> Hmm, interesting.  The cothreads code I have has to construct a base stack
> for each cothread.  If you aren't using pthreads, this can just be a
> malloc().  The main issue is that the current implementation requires two
> assembly bits to do it.  The first sets the stack pointer, the second
> jumps into the main() of that cothread.  Now, it's very likely that the
> jmp can be done as a call (it is on x86, and that has the 'advantage' of
> letting gdb show the cothread switch history, as well as providing a soft
> landing if the cothread stub falls out), saving one hassle.

   You don't need assembly except if you need to avoid the existing
longjmp implementation because it does stack checking.

  create(routine, args) {

    thread.stack = malloc()
    thread.routine= routine
    thread.args= args;
    if (i = setjmp(thread.state)) {
        /*
	 * we are the children don't touch the local stack !
	 * thread need to be a global variable
	 */
	thread.routine(thread.stack);
	suicide();
    } else {
	thread.state.SP = top(thread.stack);
    }

  }
    
  thread is launched by a switch, i.e. a sequqnce of a setjmp() on
the current thread and a longjmp on the new one.

  No need for assembly. SP can also  be computed by C code by checking
values when calling subroutines and comparing the result of longjumps.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




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