[gambit-list] Setting up scheme environment causes SDL to hang

Patrick Li patrickli.2001 at gmail.com
Thu Feb 16 01:01:48 EST 2012


Thanks for your reply Marc,

The reference to David's interface is very helpful. It works perfectly, and
I think I can get to the root of the problem with a little digging.

  -Patrick

On Wed, Feb 15, 2012 at 6:38 PM, Marc Feeley <feeley at iro.umontreal.ca>wrote:

>
> On 2012-02-15, at 9:17 PM, Patrick Li wrote:
>
> > Hi,
> >
> > I am trying to get Gambit playing well with SDL, and am running into
> some strange problems when trying to set up the scheme environment.
> >
> > This is the main() function that starts up a SDL window:
> >
> > int main(int argc, char *argv[])
> > {
> >   /* //SETUP */
> >   ___setup_params_struct setup_params;
> >   ___setup_params_reset (&setup_params);
> >   setup_params.version = ___VERSION;
> >   setup_params.linker  = SCHEME_LIBRARY_LINKER;
> >   ___setup (&setup_params);
> >
> >   x = 0;
> >   run_stuff(); //Starts a simple SDL animation
> >
> >   /* //CLEANUP */
> >   ___cleanup ();
> > }
> >
> > Currently everything is still in C, so there are *no* calls to any
> scheme functions yet.
>
> That's not necessarily the case.  When ___setup() is called, your Scheme
> program will be run and it might contain Scheme calls (in your previous
> example you were calling println for instance).  Usually this "execution"
> of your Scheme program takes care of the initializations your program
> requires.  After ___setup() returns, but before you call ___cleanup(), you
> can call Scheme functions declared using c-define in your Scheme code.
>
> >
> > I found that the animation runs for about 3 seconds before the whole
> program hangs. If I comment out __setup(&setup_params), then the program
> executes normally.
> >
> > Are there some subtleties when setting up the Gambit environment that I
> have to watch out for? Is Gambit spawning another thread and causing some
> deadlock problems? I am fairly certain that SDL is single-threaded, and the
> whole animation runs in an infinite loop.
> >
>
> The Gambit runtime is also single threaded (it does not create any OS
> threads, except on Windows to simulate interval timers, but that's not
> relevant here).
>
> The problem could be an interference between the OS resources used by SDL
> and those used by the Gambit runtime, in particular the Gambit runtime sets
> up some signal handlers, for example to implement the heartbeat interrupt.
>  Perhaps the SDL library is doing the same?
>
> I know that David St-Hilaire wrote an interface to SDL which is on the
> Gambit Dumping Grounds (the space invaders demo).  Maybe you should check
> that out to see how he did it?
>
> Marc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20120215/07706ea2/attachment.htm>


More information about the Gambit-list mailing list