From 4fd8164f439d63f709099cd0e7d879e87356c103 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 6 Dec 2019 21:41:42 +0100 Subject: [PATCH] :art: More on concurency --- src/lib/shred.c | 5 +++-- src/main.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) 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 } -- 2.43.0