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
*
* \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);
}

View File

@ -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));
}

View File

@ -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());
}

View File

@ -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