From 9fc8521e635f0984bab9b9c7aae51ba398d9d3e2 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Fri, 16 Jan 2026 00:28:46 +0100 Subject: [PATCH] sys_proc_mutex_unlock () automatically reschedule at the end --- init/init.c | 2 -- kernel/syscall/syscall.c | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/init/init.c b/init/init.c index 288ec10..fae5550 100644 --- a/init/init.c +++ b/init/init.c @@ -13,7 +13,6 @@ void mythread (void) { for (size_t i = 0; i < 3; i++) proc_test ('b'); proc_mutex_unlock (mutex_rid); - proc_sched (); } } @@ -40,6 +39,5 @@ void app_main (void) { for (size_t i = 0; i < 3; i++) proc_test ('a'); proc_mutex_unlock (mutex_rid); - proc_sched (); } } diff --git a/kernel/syscall/syscall.c b/kernel/syscall/syscall.c index 2060d91..ec6dc3e 100644 --- a/kernel/syscall/syscall.c +++ b/kernel/syscall/syscall.c @@ -142,7 +142,13 @@ DEFINE_SYSCALL (sys_proc_mutex_unlock) { if (resource == NULL) return -SR_NOT_FOUND; - return proc_mutex_unlock (proc, &resource->u.mutex) ? SR_OK : -SR_PERMISSION_ERROR; + int result = proc_mutex_unlock (proc, &resource->u.mutex) ? SR_OK : -SR_PERMISSION_ERROR; + if (result < 0) + return result; + + proc_sched (regs); + + return SR_OK; } /* int proc_drop_resource (int rid) */