hw: don't use assertions in Kernel::get_thread

ref #589
This commit is contained in:
Martin Stein 2013-09-18 22:33:56 +02:00 committed by Norman Feske
parent e5ea660e2e
commit 36111587be
3 changed files with 26 additions and 24 deletions

View File

@ -317,14 +317,19 @@ namespace Kernel
/**
* Get platform thread by ID or 0 if target is "core main" or "idle"
* Get platform thread by the kernel name of a thread
*
* \param id ID of the targeted thread or 0 if caller targets itself
* \param id kernel name of the thread or 0 if the caller targets itself
*
* \retval 0 thread doesn't exist or has no platform thread
* \retval >0 core local address of platform thread
*
* Restricted to core threads.
*/
inline Platform_thread * get_thread(unsigned const id = 0) {
return (Platform_thread *)syscall(GET_THREAD, id); }
inline Platform_thread * get_thread(unsigned const id)
{
return (Platform_thread *)syscall(GET_THREAD, id);
}
/**

View File

@ -444,21 +444,21 @@ namespace Kernel
void do_get_thread(Thread * const user)
{
/* check permissions */
assert(user->pd_id() == core_id());
/* get target */
unsigned const tid = (unsigned)user->user_arg_1();
if (user->pd_id() != core_id()) {
PERR("not entitled to read address of platform thread");
user->user_arg_0(0);
return;
}
/* lookup thread */
unsigned const id = user->user_arg_1();
Thread * t;
/* user targets a thread by ID */
if (tid) {
t = Thread::pool()->object(tid);
assert(t);
/* user targets itself */
} else t = user;
/* return target platform thread */
if (id) {
t = Thread::pool()->object(id);
if (!t) {
PERR("unknown thread");
user->user_arg_0(0);
}
} else { t = user; }
user->user_arg_0((Syscall_ret)t->platform_thread());
}

View File

@ -42,12 +42,9 @@ Native_utcb * Thread_base::utcb()
*/
Thread_base * Thread_base::myself()
{
/* get our platform thread wich holds our thread base or 0 */
Platform_thread * const pt = Kernel::get_thread();
if (pt) return pt->thread_base();
/* we are core main, the only thread beside idle with no platform thread */
else return 0;
Platform_thread * const t = Kernel::get_thread(0);
if (t) { return t->thread_base(); }
return 0;
}