[plt-scheme] capturing output from different threads

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 5 08:57:21 EST 2008

At Wed, 5 Mar 2008 10:53:33 -0000 (GMT), "Dave Griffiths" wrote:
> 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 Chongkai says, this should work the way you want: the parameters are
inherited by threads created during the scheme_eval_string_all() call.

Are all the threads created and run in the "..." above? If so, I don't
have an idea at the moment for what might be wrong; maybe a stack trace
would help.

> 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.

My first impression was that scheme_check_threads() has probably
rotted, since it's not longer used in MrEd, but it's a simple enough
function that I don't see what could be wrong. So, I'll have to
investigate more.

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



Posted on the users mailing list.