From b72001fcac18d2c37c24e423cc7e15fe900dc172 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Mon, 14 Oct 2013 09:50:18 +0800 Subject: [PATCH] kernel: mutex could only be released in thread context Mutex has the idea of ownership, only the thread which owns the mutex can release it. So rt_mutex_release could only be called in thread context. Add a debug guard to it. --- src/ipc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ipc.c b/src/ipc.c index 7e4263c0bf..0ad50bfbc5 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -777,6 +777,9 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) need_schedule = RT_FALSE; + /* only thread could release mutex because we need test the ownership */ + RT_DEBUG_IN_THREAD_CONTEXT; + /* get current thread */ thread = rt_thread_self(); -- GitLab