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. * Restricted to core threads.
*/ */
inline Platform_thread * get_thread(unsigned const id = 0) { inline Platform_thread * get_thread(unsigned const id)
return (Platform_thread *)syscall(GET_THREAD, id); } {
return (Platform_thread *)syscall(GET_THREAD, id);
}
/** /**

View File

@ -444,21 +444,21 @@ namespace Kernel
void do_get_thread(Thread * const user) void do_get_thread(Thread * const user)
{ {
/* check permissions */ /* check permissions */
assert(user->pd_id() == core_id()); if (user->pd_id() != core_id()) {
PERR("not entitled to read address of platform thread");
/* get target */ user->user_arg_0(0);
unsigned const tid = (unsigned)user->user_arg_1(); return;
}
/* lookup thread */
unsigned const id = user->user_arg_1();
Thread * t; Thread * t;
if (id) {
/* user targets a thread by ID */ t = Thread::pool()->object(id);
if (tid) { if (!t) {
t = Thread::pool()->object(tid); PERR("unknown thread");
assert(t); user->user_arg_0(0);
}
/* user targets itself */ } else { t = user; }
} else t = user;
/* return target platform thread */
user->user_arg_0((Syscall_ret)t->platform_thread()); 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() Thread_base * Thread_base::myself()
{ {
/* get our platform thread wich holds our thread base or 0 */ Platform_thread * const t = Kernel::get_thread(0);
Platform_thread * const pt = Kernel::get_thread(); if (t) { return t->thread_base(); }
if (pt) return pt->thread_base(); return 0;
/* we are core main, the only thread beside idle with no platform thread */
else return 0;
} }