unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* multi-threading
@ 2008-07-05 22:14 Henri Häkkinen
  2008-07-05 22:34 ` multi-threading Neil Jerram
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Häkkinen @ 2008-07-05 22:14 UTC (permalink / raw
  To: guile-user

Hello,

I am trying to use Guile from an multi-threaded application. Here is a 
sample code:

// test.c

#include <libguile.h>
#include <pthread.h>

static void *
inner_thread (void *p)
{
   scm_c_eval_string ("(newline)");
   return NULL;
}

static void *
thread (void *p)
{
   return scm_with_guile (inner_thread, p);
}

static void
inner_main (void *closure, int argc, char **argv)
{
   pthread_t thr;
   pthread_create (&thr, NULL, thread, NULL);
   pthread_join (thr, NULL);
}

int
main (int argc, char **argv)
{
   scm_boot_guile (argc, argv, inner_main, NULL);
   return 0;
}


I have read from the Guile manual that I should be able to use threads 
in this way. However, I get ERROR: Stack overflow. Do you know where is 
the problem? Running `guile --version` returns "Guile 1.8.1".

--
Henri Häkkinen




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: multi-threading
  2008-07-05 22:14 multi-threading Henri Häkkinen
@ 2008-07-05 22:34 ` Neil Jerram
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Jerram @ 2008-07-05 22:34 UTC (permalink / raw
  To: Henri Häkkinen; +Cc: guile-user

2008/7/5 Henri Häkkinen <henri.hakkinen@pp2.inet.fi>:
> Hello,
>
> I am trying to use Guile from an multi-threaded application. Here is a
> sample code:
>
> // test.c
>
> #include <libguile.h>
> #include <pthread.h>
>
> static void *
> inner_thread (void *p)
> {
>  scm_c_eval_string ("(newline)");
>  return NULL;
> }
>
> static void *
> thread (void *p)
> {
>  return scm_with_guile (inner_thread, p);
> }
>
> static void
> inner_main (void *closure, int argc, char **argv)
> {
>  pthread_t thr;
>  pthread_create (&thr, NULL, thread, NULL);
>  pthread_join (thr, NULL);
> }
>
> int
> main (int argc, char **argv)
> {
>  scm_boot_guile (argc, argv, inner_main, NULL);
>  return 0;
> }
>
>
> I have read from the Guile manual that I should be able to use threads in
> this way. However, I get ERROR: Stack overflow. Do you know where is the
> problem? Running `guile --version` returns "Guile 1.8.1".

Your program looks OK to me.  There is a known stack overflow problem
on some OSs, when just trying to load boot-9.scm, and when libguile is
compiled without much optimization.  What OS are you running on?
Also, if you could manage to test the same program with the latest
release (1.8.5), please do that and let us know the result.

         Neil




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-05 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-05 22:14 multi-threading Henri Häkkinen
2008-07-05 22:34 ` multi-threading Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).