[plt-scheme] threads and mzscheme

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 23 16:27:06 EDT 2005

At Mon, 23 May 2005 21:13:07 +0200, Hans Oesterholt-Dijkema wrote:
> Hans Oesterholt-Dijkema schreef:
> >>>
> >> This is probably where the pain is! I'm making a call to C for the 
> >> database connection, which
> >> will probably block the mzscheme threading system! I'll probably want 
> >> to make the database
> >> call asynchronous and wait on a semaphore in mzscheme for the 
> >> database to return with a
> >> result ( I'll need to change sqli :(( ).
> >
> Could I use C threads (posix or windows) to call PQExec and let the C 
> system call
> back through the given C thread into (which is not the same as the 
> mzscheme system thread!),
>  updating an mzscheme semaphore? Looks very dangerous to me.

You're right --- it won't work. MzScheme semaphores work only with the
MzScheme thread scheduler.

You'll need to use whatever synchronization primitives the C thread
system provides, and then connect to the MzScheme scheduler through
scheme_block_until() or scheme_add_evt().


Posted on the users mailing list.