diff --git a/base-hw/include/kernel/interface.h b/base-hw/include/kernel/interface.h index 17d974c776..c36923ae05 100644 --- a/base-hw/include/kernel/interface.h +++ b/base-hw/include/kernel/interface.h @@ -95,18 +95,13 @@ namespace Kernel /** - * Let an already started thread participate in CPU scheduling + * Cancel blocking of a thread if possible * * \param thread_id kernel name of the targeted thread * - * \retval 0 succeeded and thread was paused beforehand - * \retval 1 succeeded and thread was active beforehand - * \retval -1 failed - * - * If the targeted thread blocks for any event except a 'start_thread' - * call this call cancels the blocking. + * \return wether thread was in a cancelable blocking beforehand */ - inline int resume_thread(unsigned const thread_id) + inline bool resume_thread(unsigned const thread_id) { return call(call_id_resume_thread(), thread_id); } diff --git a/base-hw/src/base/lock/lock_helper.h b/base-hw/src/base/lock/lock_helper.h index 6b2032cb4e..db4b02bbdc 100644 --- a/base-hw/src/base/lock/lock_helper.h +++ b/base-hw/src/base/lock/lock_helper.h @@ -52,7 +52,7 @@ static inline void thread_switch_to(Genode::Thread_base * const t) static inline bool thread_check_stopped_and_restart(Genode::Thread_base * const t) { - return Kernel::resume_thread(native_thread_id(t)) == 0; + return Kernel::resume_thread(native_thread_id(t)); } diff --git a/base-hw/src/core/kernel/thread.cc b/base-hw/src/core/kernel/thread.cc index 2a71bc4796..c6bd567055 100644 --- a/base-hw/src/core/kernel/thread.cc +++ b/base-hw/src/core/kernel/thread.cc @@ -129,28 +129,24 @@ void Thread::_await_ipc_failed() } -int Thread::_resume() +bool Thread::_resume() { switch (_state) { case AWAITS_RESUME: _schedule(); - return 0; - case SCHEDULED: - return 1; + return true; case AWAITS_IPC: Ipc_node::cancel_waiting(); - return 0; + return true; case AWAITS_SIGNAL: Signal_handler::cancel_waiting(); - return 0; + return true; case AWAITS_SIGNAL_CONTEXT_KILL: Signal_context_killer::cancel_waiting(); - return 0; - case AWAITS_START: - case STOPPED:; + return true; + default: + return false; } - PWRN("failed to resume thread"); - return -1; } @@ -412,20 +408,20 @@ void Thread::_call_pause_thread() void Thread::_call_resume_thread() { /* lookup thread */ - Thread * const t = Thread::pool()->object(user_arg_1()); - if (!t) { - PWRN("unknown thread"); - user_arg_0(-1); + Thread * const thread = Thread::pool()->object(user_arg_1()); + if (!thread) { + PWRN("failed to lookup thread"); + user_arg_0(false); return; } /* check permissions */ - if (!_core() && pd_id() != t->pd_id()) { + if (!_core() && pd_id() != thread->pd_id()) { PWRN("not entitled to resume thread"); - user_arg_0(-1); + _stop(); return; } - /* resume targeted thread */ - user_arg_0(t->_resume()); + /* resume thread */ + user_arg_0(thread->_resume()); } diff --git a/base-hw/src/core/kernel/thread.h b/base-hw/src/core/kernel/thread.h index e0a2e9e536..e11371bfc3 100644 --- a/base-hw/src/core/kernel/thread.h +++ b/base-hw/src/core/kernel/thread.h @@ -152,13 +152,11 @@ class Kernel::Thread void _stop(); /** - * Try to escape from blocking state, if in any, and resume execution + * Cancel blocking if possible * - * \retval -1 failed - * \retval 0 succeeded, execution was paused - * \retval 1 succeeded, execution was not paused + * \return wether thread was in a cancelable blocking beforehand */ - int _resume(); + bool _resume(); /** * Handle an exception thrown by the memory management unit