[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libguile thread safety
From: |
Panicz Maciej Godek |
Subject: |
Re: libguile thread safety |
Date: |
Sat, 4 Jan 2014 02:22:11 +0100 |
I concluded that this might be a solution. I tested it with 2.0.5 from
ubuntu repository. I had to add GC_allow_register_threads (and link
against gc, accordingly), because otherwise the program aborted with
the message "Threads explicit registering is not previously enabled"
whenever it attempted to create a thread.
For some reason the initialization routine needs to call
scm_c_eval_string; otherwise it doesn't help.
The solution doesn't fill me with joy, but I hope it works for you
#include <libguile.h>
#include <pthread.h>
void *guile_wrapper (void *data) {
scm_c_eval_string ("(display \"Hello\n\")");
return NULL;
}
void *thread_func (void *data) {
scm_with_guile (&guile_wrapper, NULL);
return NULL;
}
void *do_nothing(void *unused) {
scm_c_eval_string("(noop)");
return NULL;
}
int main () {
pthread_t thread1;
pthread_t thread2;
GC_allow_register_threads();
scm_with_guile(do_nothing, NULL);
pthread_create (&thread1, NULL, thread_func, NULL);
pthread_create (&thread2, NULL, thread_func, NULL);
pthread_join (thread1, NULL);
pthread_join (thread2, NULL);
return 0;
}
Re: libguile thread safety, Mark H Weaver, 2014/01/03
- Re: libguile thread safety, Chris Vine, 2014/01/04
- Re: libguile thread safety, Chris Vine, 2014/01/04
- Re: libguile thread safety, Panicz Maciej Godek, 2014/01/04
- Re: libguile thread safety, Chris Vine, 2014/01/04
- Re: libguile thread safety, Mark H Weaver, 2014/01/04
- Re: libguile thread safety, Chris Vine, 2014/01/04
- Re: libguile thread safety, Panicz Maciej Godek, 2014/01/04