hw: simplify return value of Kernel::resume_thread

ref #1101
This commit is contained in:
Martin Stein 2014-03-17 12:12:04 +01:00 committed by Norman Feske
parent 6974abcf41
commit c72f91fefb
4 changed files with 22 additions and 33 deletions

View File

@ -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 * \param thread_id kernel name of the targeted thread
* *
* \retval 0 succeeded and thread was paused beforehand * \return wether thread was in a cancelable blocking 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.
*/ */
inline int resume_thread(unsigned const thread_id) inline bool resume_thread(unsigned const thread_id)
{ {
return call(call_id_resume_thread(), thread_id); return call(call_id_resume_thread(), thread_id);
} }

View File

@ -52,7 +52,7 @@ static inline void thread_switch_to(Genode::Thread_base * const t)
static inline bool static inline bool
thread_check_stopped_and_restart(Genode::Thread_base * const t) 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));
} }

View File

@ -129,28 +129,24 @@ void Thread::_await_ipc_failed()
} }
int Thread::_resume() bool Thread::_resume()
{ {
switch (_state) { switch (_state) {
case AWAITS_RESUME: case AWAITS_RESUME:
_schedule(); _schedule();
return 0; return true;
case SCHEDULED:
return 1;
case AWAITS_IPC: case AWAITS_IPC:
Ipc_node::cancel_waiting(); Ipc_node::cancel_waiting();
return 0; return true;
case AWAITS_SIGNAL: case AWAITS_SIGNAL:
Signal_handler::cancel_waiting(); Signal_handler::cancel_waiting();
return 0; return true;
case AWAITS_SIGNAL_CONTEXT_KILL: case AWAITS_SIGNAL_CONTEXT_KILL:
Signal_context_killer::cancel_waiting(); Signal_context_killer::cancel_waiting();
return 0; return true;
case AWAITS_START: default:
case STOPPED:; return false;
} }
PWRN("failed to resume thread");
return -1;
} }
@ -412,20 +408,20 @@ void Thread::_call_pause_thread()
void Thread::_call_resume_thread() void Thread::_call_resume_thread()
{ {
/* lookup thread */ /* lookup thread */
Thread * const t = Thread::pool()->object(user_arg_1()); Thread * const thread = Thread::pool()->object(user_arg_1());
if (!t) { if (!thread) {
PWRN("unknown thread"); PWRN("failed to lookup thread");
user_arg_0(-1); user_arg_0(false);
return; return;
} }
/* check permissions */ /* check permissions */
if (!_core() && pd_id() != t->pd_id()) { if (!_core() && pd_id() != thread->pd_id()) {
PWRN("not entitled to resume thread"); PWRN("not entitled to resume thread");
user_arg_0(-1); _stop();
return; return;
} }
/* resume targeted thread */ /* resume thread */
user_arg_0(t->_resume()); user_arg_0(thread->_resume());
} }

View File

@ -152,13 +152,11 @@ class Kernel::Thread
void _stop(); void _stop();
/** /**
* Try to escape from blocking state, if in any, and resume execution * Cancel blocking if possible
* *
* \retval -1 failed * \return wether thread was in a cancelable blocking beforehand
* \retval 0 succeeded, execution was paused
* \retval 1 succeeded, execution was not paused
*/ */
int _resume(); bool _resume();
/** /**
* Handle an exception thrown by the memory management unit * Handle an exception thrown by the memory management unit