hw: don't use assert in Kernel::pause_thread

ref #1101
This commit is contained in:
Martin Stein 2014-03-16 15:33:45 +01:00 committed by Norman Feske
parent 055b7c57b6
commit 5e940da040
1 changed files with 18 additions and 11 deletions

View File

@ -382,21 +382,28 @@ void Thread::_call_start_thread()
void Thread::_call_pause_thread() void Thread::_call_pause_thread()
{ {
unsigned const tid = user_arg_1(); /* take a shortcut if a thread wants to pause itself */
unsigned const thread_id = user_arg_1();
/* shortcut for a thread to pause itself */ if (!thread_id || thread_id == id()) {
if (!tid) {
_pause(); _pause();
user_arg_0(0); user_arg_0(0);
return; return;
} }
/* check permissions */
/* get targeted thread and check permissions */ if (!_core()) {
Thread * const t = Thread::pool()->object(tid); PWRN("not entitled to pause thread");
assert(t && (_core() || this == t)); _stop();
return;
/* pause targeted thread */ }
t->_pause(); /* lookup thread */
Thread * const thread = Thread::pool()->object(thread_id);
if (!thread) {
PWRN("failed to lookup thread");
user_arg_0(-1);
return;
}
/* pause thread */
thread->_pause();
user_arg_0(0); user_arg_0(0);
} }