mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 07:38:28 +00:00
base: remove env_deprecated from thread-start code
This patch replaces the internal use 'env_deprecated()' from the implementation of the thread API in the base library. It also replaces the global accessor 'main_thread_cap' by the explicit propagation of the main-thread's capability to the single point of use via a new 'init_thread_bootstap' function. Issue #4784
This commit is contained in:
@ -197,6 +197,9 @@ void Genode::init_platform()
|
||||
|
||||
init_log(platform.parent);
|
||||
init_rpc_cap_alloc(platform.parent);
|
||||
init_thread(platform.cpu, platform.rm);
|
||||
init_thread_start(platform.pd_cap);
|
||||
init_thread_bootstrap(platform.parent.main_thread_cap());
|
||||
|
||||
env_stack_area_region_map = &platform.pd._stack_area;
|
||||
env_stack_area_ram_allocator = &platform.pd;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <base/log.h>
|
||||
#include <linux_native_cpu/client.h>
|
||||
#include <cpu_thread/client.h>
|
||||
#include <deprecated/env.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/stack.h>
|
||||
@ -30,11 +29,27 @@
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
extern int main_thread_futex_counter;
|
||||
|
||||
|
||||
static void empty_signal_handler(int) { }
|
||||
|
||||
|
||||
static Capability<Pd_session> pd_session_cap(Capability<Pd_session> pd_cap = { })
|
||||
{
|
||||
static Capability<Pd_session> cap = pd_cap; /* defined once by 'init_thread_start' */
|
||||
return cap;
|
||||
}
|
||||
|
||||
|
||||
static Thread_capability main_thread_cap(Thread_capability main_cap = { })
|
||||
{
|
||||
static Thread_capability cap = main_cap; /* defined once by 'init_thread_bootstrap' */
|
||||
return cap;
|
||||
}
|
||||
|
||||
|
||||
static Blockade &startup_lock()
|
||||
{
|
||||
static Blockade blockade;
|
||||
@ -88,12 +103,14 @@ void Thread::_thread_start()
|
||||
void Thread::_init_platform_thread(size_t /* weight */, Type type)
|
||||
{
|
||||
/* if no cpu session is given, use it from the environment */
|
||||
if (!_cpu_session)
|
||||
_cpu_session = env_deprecated()->cpu_session();
|
||||
if (!_cpu_session) {
|
||||
error("Thread::_init_platform_thread: _cpu_session not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
/* for normal threads create an object at the CPU session */
|
||||
if (type == NORMAL) {
|
||||
_thread_cap = _cpu_session->create_thread(env_deprecated()->pd_session_cap(),
|
||||
_thread_cap = _cpu_session->create_thread(pd_session_cap(),
|
||||
_stack->name().string(),
|
||||
Affinity::Location(),
|
||||
Weight());
|
||||
@ -165,3 +182,15 @@ void Thread::start()
|
||||
/* wait until the 'thread_start' function got entered */
|
||||
startup_lock().block();
|
||||
}
|
||||
|
||||
|
||||
void Genode::init_thread_start(Capability<Pd_session> pd_cap)
|
||||
{
|
||||
pd_session_cap(pd_cap);
|
||||
}
|
||||
|
||||
|
||||
void Genode::init_thread_bootstrap(Thread_capability main_cap)
|
||||
{
|
||||
main_thread_cap(main_cap);
|
||||
}
|
||||
|
Reference in New Issue
Block a user