Kill off pthread itimer threads for places
svn: r16402
This commit is contained in:
parent
8a45f34acd
commit
c6bd8a596d
|
@ -495,6 +495,12 @@ Scheme_Env *scheme_place_instance_init(void *stack_base) {
|
||||||
return place_instance_init_post_kernel();
|
return place_instance_init_post_kernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scheme_place_instance_destroy() {
|
||||||
|
#if defined(USE_PTHREAD_THREAD_TIMER) && defined(MZ_USE_PLACES)
|
||||||
|
kill_green_thread_timer();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void make_kernel_env(void)
|
static void make_kernel_env(void)
|
||||||
{
|
{
|
||||||
Scheme_Env *env;
|
Scheme_Env *env;
|
||||||
|
|
|
@ -254,6 +254,7 @@ static void *place_start_proc(void *data_arg) {
|
||||||
|
|
||||||
a[0] = scheme_places_deep_copy(place_data->channel);
|
a[0] = scheme_places_deep_copy(place_data->channel);
|
||||||
scheme_apply(place_main, 1, a);
|
scheme_apply(place_main, 1, a);
|
||||||
|
scheme_place_instance_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return scheme_true;
|
return scheme_true;
|
||||||
|
|
|
@ -8444,6 +8444,7 @@ static void scheme_start_itimer_thread(long usec)
|
||||||
typedef struct ITimer_Data {
|
typedef struct ITimer_Data {
|
||||||
int itimer;
|
int itimer;
|
||||||
int state;
|
int state;
|
||||||
|
int die;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
|
@ -8464,16 +8465,21 @@ static void *green_thread_timer(void *data)
|
||||||
itimer_data = (ITimer_Data *)data;
|
itimer_data = (ITimer_Data *)data;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
if (itimer_data->die) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
usleep(itimer_data->delay);
|
usleep(itimer_data->delay);
|
||||||
*(itimer_data->fuel_counter_ptr) = 0;
|
*(itimer_data->fuel_counter_ptr) = 0;
|
||||||
*(itimer_data->jit_stack_boundary_ptr) = (unsigned long)-1;
|
*(itimer_data->jit_stack_boundary_ptr) = (unsigned long)-1;
|
||||||
|
|
||||||
pthread_mutex_lock(&itimer_data->mutex);
|
pthread_mutex_lock(&itimer_data->mutex);
|
||||||
if (itimer_data->state) {
|
if (!itimer_data->die) {
|
||||||
itimer_data->state = 0;
|
if (itimer_data->state) {
|
||||||
} else {
|
itimer_data->state = 0;
|
||||||
itimer_data->state = -1;
|
} else {
|
||||||
pthread_cond_wait(&itimer_data->cond, &itimer_data->mutex);
|
itimer_data->state = -1;
|
||||||
|
pthread_cond_wait(&itimer_data->cond, &itimer_data->mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&itimer_data->mutex);
|
pthread_mutex_unlock(&itimer_data->mutex);
|
||||||
}
|
}
|
||||||
|
@ -8485,6 +8491,7 @@ END_XFORM_SKIP;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void start_green_thread_timer(long usec) {
|
static void start_green_thread_timer(long usec) {
|
||||||
|
itimerdata.die = 0;
|
||||||
itimerdata.delay = usec;
|
itimerdata.delay = usec;
|
||||||
itimerdata.fuel_counter_ptr = &scheme_fuel_counter;
|
itimerdata.fuel_counter_ptr = &scheme_fuel_counter;
|
||||||
itimerdata.jit_stack_boundary_ptr = &scheme_jit_stack_boundary;
|
itimerdata.jit_stack_boundary_ptr = &scheme_jit_stack_boundary;
|
||||||
|
@ -8494,6 +8501,23 @@ static void start_green_thread_timer(long usec) {
|
||||||
itimerdata.itimer = 1;
|
itimerdata.itimer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kill_green_thread_timer() {
|
||||||
|
void *rc;
|
||||||
|
pthread_mutex_lock(&itimerdata.mutex);
|
||||||
|
itimerdata.die = 1;
|
||||||
|
if (!itimerdata.state) {
|
||||||
|
/* itimer thread is currently running working */
|
||||||
|
} else if (itimerdata.state < 0) {
|
||||||
|
/* itimer thread is waiting on cond */
|
||||||
|
pthread_cond_signal(&itimerdata.cond);
|
||||||
|
} else {
|
||||||
|
/* itimer thread is working, and we've already
|
||||||
|
asked it to continue */
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&itimerdata.mutex);
|
||||||
|
pthread_join(itimerdata.thread, &rc);
|
||||||
|
}
|
||||||
|
|
||||||
static void kickoff_green_thread_timer(long usec) {
|
static void kickoff_green_thread_timer(long usec) {
|
||||||
pthread_mutex_lock(&itimerdata.mutex);
|
pthread_mutex_lock(&itimerdata.mutex);
|
||||||
itimerdata.delay = usec;
|
itimerdata.delay = usec;
|
||||||
|
|
|
@ -3253,6 +3253,8 @@ typedef struct Scheme_Place {
|
||||||
} Scheme_Place;
|
} Scheme_Place;
|
||||||
|
|
||||||
Scheme_Env *scheme_place_instance_init();
|
Scheme_Env *scheme_place_instance_init();
|
||||||
|
void scheme_place_instance_destroy();
|
||||||
|
void kill_green_thread_timer();
|
||||||
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
/* engine */
|
/* engine */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user