[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Threading/Process Question
On Wed, Nov 22, 2000 at 07:43:24PM -0800, Matthew Flatt wrote:
> The main problem here is that NULL is not allowed as the first argument
> to scheme_thread. It needs a procedure to start executing in the new
> thread.
>
> Also, you don't want to supply the "config" (a set of parameter values)
> of the current thread to the created one, otherwise they'll share
> parameter values.
>
> Instead, create a new one:
>
> scheme_thread(thunk, scheme_make_config(scheme_config));
>
> [Note: the docs claim that NULL is a legal second argument to
> scheme_thread(), but it isn't anymore.]
>
Must the new procedure be long-lived? E.g., can it be something
as trivial as (+ 1 2)?
> > ... Still later, I want to get back to thread "A"
> > scheme_swap_process(proc);
> >
> > However, this doesn't work right -- it causes me to segfault
> > when I try to execute code after the scheme_swap_process.
>
> Actually, the segfault is within scheme_swap_process(), because it's
> trying to jump to the NULL procedure, right?
>
Exactly!
> > Does "scheme_thread" return a real, usable Scheme_Process*,
>
> Yes, assuming that it gets valid procedure and config values.
>
Thanks. Onward and upward....
Happy Thanksgiving!
-Brent