From 8c2e20c3aa67f08eb6d2788f703c7b7a6cbe9993 Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Sat, 9 Dec 2017 15:31:32 +0900 Subject: [PATCH] uti: Fix uti thread on the McKernel side blocks others in do_syscall() It could block other threads on the same CPU in do_syscall() since it busy-waits after woken up because it's not allowed to sleep again. --- kernel/syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index b8682fc4..b8ea8142 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -320,11 +320,11 @@ long do_syscall(struct syscall_request *req, int cpu, int pid) flags = cpu_disable_interrupt_save(); /* Try to sleep until notified */ - if (__sync_bool_compare_and_swap(&res.req_thread_status, - IHK_SCD_REQ_THREAD_SPINNING, - IHK_SCD_REQ_THREAD_DESCHEDULED)) { - - dkprintf("%s: tid %d waiting for syscall reply...\n", + if (res.req_thread_status == IHK_SCD_REQ_THREAD_DESCHEDULED || + __sync_bool_compare_and_swap(&res.req_thread_status, + IHK_SCD_REQ_THREAD_SPINNING, + IHK_SCD_REQ_THREAD_DESCHEDULED)) { + kprintf("%s: tid %d waiting for syscall reply...\n", __FUNCTION__, thread->tid); waitq_init(&thread->scd_wq); waitq_prepare_to_wait(&thread->scd_wq, &scd_wq_entry,