From: Jérémie Astor Date: Fri, 6 Dec 2019 20:41:42 +0000 (+0100) Subject: :art: More on concurency X-Git-Tag: nightly~2068^2~6 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=4fd8164f439d63f709099cd0e7d879e87356c103;p=gwion.git :art: More on concurency --- diff --git a/src/lib/shred.c b/src/lib/shred.c index 7f9daa51..b878c537 100644 --- a/src/lib/shred.c +++ b/src/lib/shred.c @@ -215,6 +215,7 @@ void fork_retval(const M_Object o) { static ANN void* fork_run(void* data) { VM *vm = (VM*)data; const M_Object me = vm->shreduler->list->self->info->me; +//++me->ref; while(vm->bbq->is_running) { vm_run(vm); ++vm->bbq->pos; @@ -224,7 +225,7 @@ static ANN void* fork_run(void* data) { fork_retval(me); *(m_int*)(me->data + o_fork_done) = 1; broadcast(*(M_Object*)(me->data + o_fork_ev)); - } else + } else if(me->ref > 1) release(me, ME(me)); vm_unlock(vm->parent); THREAD_RETURN(NULL); @@ -235,7 +236,7 @@ ANN void fork_launch(VM const* vm, const M_Object o, const m_uint sz) { if(vm_running(vm)) { FORK_RETSIZE(o) = sz; THREAD_CREATE(FORK_THREAD(o), fork_run, ME(o)->info->vm); - } + } else release(o, ME(o)); vm_unlock(vm); } diff --git a/src/main.c b/src/main.c index 1d7f6dd5..0108e477 100644 --- a/src/main.c +++ b/src/main.c @@ -10,6 +10,7 @@ static void sig(int unused NUSED) { #ifdef BUILD_ON_WINDOWS exit(EXIT_FAILURE); #else + pthread_kill(pthread_self(), SIGTERM); pthread_exit(NULL); #endif }