mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
parent
e5ea660e2e
commit
36111587be
@ -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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user