1996-10-15
1996-10-15 04:04:07 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
a29e027722bd2cb282e52bdbcb121925f829a697
(33 lines)
(+29/-4)
[
Show
| Annotate
]
Branch: 7.9
check_threads_etc() callbacks recoded...
Rev: src/gc.c:1.3
Rev: src/gc.h:1.4
Rev: src/interpret.c:1.7
Rev: src/interpret.h:1.4
Rev: src/las.c:1.4
Rev: src/object.c:1.2
Rev: src/object.h:1.2
Rev: src/signal_handler.c:1.4
Rev: src/threads.c:1.8
Rev: src/threads.h:1.5
1:
#include "global.h"
+
+ int num_threads = 1;
+ int threads_disabled = 0;
+
+ #ifdef _REENTRANT
#include "threads.h"
#include "array.h"
#include "object.h"
#include "macros.h"
-
+ #include "callback.h"
- int num_threads = 1;
- int threads_disabled = 0;
+
struct object *thread_id;
-
+ static struct callback *threads_evaluator_callback=0;
- #ifdef _REENTRANT
-
+
MUTEX_T interpreter_lock = PTHREAD_MUTEX_INITIALIZER;
struct program *mutex_key = 0;
struct program *thread_id_prog = 0;
21: Inside #if defined(_REENTRANT)
struct array *args;
};
+ static void check_threads(struct callback *cb, void *arg)
+ {
+ THREADS_ALLOW();
+
+ /* Allow other threads to run */
+
+ THREADS_DISALLOW();
+ }
+
void *new_thread_func(void * data)
{
struct thread_starter arg = *(struct thread_starter *)data;
61: Inside #if defined(_REENTRANT)
cleanup_interpret();
num_threads--;
+ if(!num_threads)
+ {
+ remove_callback(threads_evaluator_callback);
+ threads_evaluator_callback=0;
+ }
mt_unlock(& interpreter_lock);
th_exit(0);
}
78: Inside #if defined(_REENTRANT)
if(!tmp)
{
num_threads++;
+
+ if(num_threads == 1 && !threads_evaluator_callback)
+ {
+ threads_evaluator_callback=add_to_callback(&evaluator_callbacks,
+ check_threads, 0,0);
+ }
+
push_object(arg->id);
arg->id->refs++;
} else {