[plt-scheme] capturing output from different threads

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Wed Mar 5 07:43:29 EST 2008

Dave Griffiths wrote:
> Hi all,
> I've been capturing the output from an embedded interpreter like so:
> outport = scheme_make_byte_string_output_port();
> errport = scheme_make_byte_string_output_port();
> scheme_set_param(scheme_current_config(), MZCONFIG_OUTPUT_PORT, outport);
> scheme_set_param(scheme_current_config(), MZCONFIG_ERROR_PORT, errport);
> ...
> scheme_eval_string_all(...)
> ...
> outmsg=scheme_get_sized_byte_string_output(outport,&size);
> errmsg=scheme_get_sized_byte_string_output(errport,&size);
> But this seems to crash the garbage collector elsewhere when I spawn a plt
> thread in my script. Reading the docs it seems that scheme_set_param only
> works for one thread, so I can imagine it would only work for the main
> thread, so 1) is there a way to get new threads to inherit the main
> thread's parameters and 2) will it also make the garbage collector happy?
> ;)

As the doc says, scheme_set_param only works for the current thread. For 
your embedded Scheme program, I assume for all C code, the current 
thread means the main Scheme thread, right?
For your question1: All newly-created thread inherits the parameter 
settings of the creating thread.

> Also maybe related, I find that calling scheme_eval_string_all on the
> interpreter causes all threads to get run, calling scheme_check_threads
> doesnt seem to make any difference.

I didn't get what you mean here. But that's looks like the correct behaver.

> I'm still on 372 btw - has this area changed with v4?

You are fine. V4 is only in alpha stage now.

> cheers,
> dave

Posted on the users mailing list.