mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-14 13:18:19 +00:00
Assign threads to PD at its creation time
This patch replaces the former 'Pd_session::bind_thread' function by a PD-capability argument of the 'Cpu_session::create_thread' function, and removes the ancient thread-start protocol via 'Rm_session::add_client' and 'Cpu_session::set_pager'. Threads are now bound to PDs at their creation time and implicitly paged according to the address space of the PD. Note the API change: This patch changes the signature of the 'Child' and 'Process' constructors. There is a new 'address_space' argument, which represents the region map representing the child's address space. It is supplied separately to the PD session capability (which principally can be invoked to obtain the PD's address space) to allow the population of the address space without relying on an 'Pd_session::address_space' RPC call. Furthermore, a new (optional) env_pd argument allows the explicit overriding of the PD capability handed out to the child as part of its environment. It can be used to intercept the interaction of the child with its PD session at core. This is used by Noux. Issue #1938
This commit is contained in:
committed by
Christian Helmuth
parent
2bc8a0f76a
commit
b49e588c1c
@ -56,6 +56,7 @@ Process::Process(Dataspace_capability elf_data_ds_cap,
|
||||
Pd_session_capability pd_session_cap,
|
||||
Ram_session_capability ram_session_cap,
|
||||
Cpu_session_capability cpu_session_cap,
|
||||
Region_map &,
|
||||
Parent_capability parent_cap,
|
||||
char const *name)
|
||||
:
|
||||
@ -80,7 +81,8 @@ Process::Process(Dataspace_capability elf_data_ds_cap,
|
||||
* the 'Platform_env' of the new process.
|
||||
*/
|
||||
enum { WEIGHT = Cpu_session::DEFAULT_WEIGHT };
|
||||
_thread0_cap = _cpu_session_client.create_thread(WEIGHT, name);
|
||||
_thread0_cap = _cpu_session_client.create_thread(pd_session_cap,
|
||||
WEIGHT, name);
|
||||
|
||||
Linux_native_pd_client
|
||||
lx_pd(static_cap_cast<Linux_native_pd>(_pd_session_client.native_pd()));
|
||||
|
@ -50,14 +50,6 @@ void Region_map_client::detach(Local_addr local_addr) {
|
||||
return _local(*this)->detach(local_addr); }
|
||||
|
||||
|
||||
Pager_capability Region_map_client::add_client(Thread_capability thread) {
|
||||
return _local(*this)->add_client(thread); }
|
||||
|
||||
|
||||
void Region_map_client::remove_client(Pager_capability pager) {
|
||||
_local(*this)->remove_client(pager); }
|
||||
|
||||
|
||||
void Region_map_client::fault_handler(Signal_context_capability /*handler*/)
|
||||
{
|
||||
/*
|
||||
|
@ -83,7 +83,8 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
|
||||
|
||||
/* for normal threads create an object at the CPU session */
|
||||
if (type == NORMAL) {
|
||||
_thread_cap = _cpu_session->create_thread(weight, _stack->name().string());
|
||||
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(),
|
||||
weight, _stack->name().string());
|
||||
return;
|
||||
}
|
||||
/* adjust initial object state for main threads */
|
||||
|
@ -53,6 +53,10 @@ namespace Genode {
|
||||
template <typename FUNC>
|
||||
auto apply(Pager_capability, FUNC f) -> decltype(f(nullptr)) {
|
||||
return f(nullptr); }
|
||||
|
||||
Pager_capability manage(Pager_object *) { return Pager_capability(); }
|
||||
|
||||
void dissolve(Pager_object *) { }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,16 @@
|
||||
|
||||
#include <base/allocator.h>
|
||||
|
||||
namespace Genode { struct Platform_pd; }
|
||||
namespace Genode {
|
||||
struct Platform_pd;
|
||||
struct Platform_thread;
|
||||
}
|
||||
|
||||
struct Genode::Platform_pd { Platform_pd(Allocator *, char const *) { } };
|
||||
struct Genode::Platform_pd
|
||||
{
|
||||
Platform_pd(Allocator *, char const *) { }
|
||||
|
||||
bool bind_thread(Platform_thread *) { return true; }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */
|
||||
|
@ -19,6 +19,7 @@
|
||||
/* Genode includes */
|
||||
#include <base/thread_state.h>
|
||||
#include <cpu_session/cpu_session.h>
|
||||
#include <base/weak_ptr.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/server_socket_pair.h>
|
||||
@ -30,6 +31,8 @@ namespace Genode {
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
class Address_space;
|
||||
|
||||
/*
|
||||
* We hold all Platform_thread objects in a list in order to be able to
|
||||
* reflect SIGCHLD as exception signals. When a SIGCHILD occurs, we
|
||||
@ -81,7 +84,8 @@ namespace Genode {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_thread(size_t, const char *name, unsigned priority, addr_t);
|
||||
Platform_thread(size_t, const char *name, unsigned priority,
|
||||
Affinity::Location, addr_t);
|
||||
|
||||
~Platform_thread();
|
||||
|
||||
@ -174,6 +178,10 @@ namespace Genode {
|
||||
* Return execution time consumed by the thread
|
||||
*/
|
||||
unsigned long long execution_time() const { return 0; }
|
||||
|
||||
Weak_ptr<Address_space> address_space() { return Weak_ptr<Address_space>(); }
|
||||
|
||||
unsigned long pager_object_badge() const { return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,9 @@
|
||||
#include <base/rpc_server.h>
|
||||
#include <region_map/region_map.h>
|
||||
|
||||
/* Core includes */
|
||||
/* core includes */
|
||||
#include <pager.h>
|
||||
#include <platform_thread.h>
|
||||
|
||||
namespace Genode {
|
||||
struct Rm_client;
|
||||
@ -46,16 +47,14 @@ class Genode::Region_map_component : public Rpc_object<Region_map>,
|
||||
|
||||
void upgrade_ram_quota(size_t ram_quota) { }
|
||||
|
||||
void add_client(Rm_client &) { }
|
||||
void remove_client(Rm_client &) { }
|
||||
|
||||
Local_addr attach(Dataspace_capability, size_t, off_t, bool, Local_addr, bool) {
|
||||
return (addr_t)0; }
|
||||
|
||||
void detach(Local_addr) { }
|
||||
|
||||
Pager_capability add_client(Thread_capability) {
|
||||
return Pager_capability(); }
|
||||
|
||||
void remove_client(Pager_capability) { }
|
||||
|
||||
void fault_handler(Signal_context_capability) { }
|
||||
|
||||
State state() { return State(); }
|
||||
@ -69,6 +68,13 @@ class Genode::Region_map_component : public Rpc_object<Region_map>,
|
||||
struct Genode::Rm_member { Region_map_component *member_rm() { return 0; } };
|
||||
|
||||
|
||||
struct Genode::Rm_client : Pager_object, Rm_member { };
|
||||
struct Genode::Rm_client : Pager_object, Rm_member
|
||||
{
|
||||
Rm_client(Cpu_session_capability, Thread_capability,
|
||||
Region_map_component *rm, unsigned long badge,
|
||||
Weak_ptr<Address_space> &address_space,
|
||||
Affinity::Location location)
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__REGION_MAP_COMPONENT_H_ */
|
||||
|
@ -14,9 +14,7 @@
|
||||
#ifndef _CORE__INCLUDE__UTIL_H_
|
||||
#define _CORE__INCLUDE__UTIL_H_
|
||||
|
||||
namespace Genode {
|
||||
constexpr size_t get_page_size_log2() { return 12; }
|
||||
constexpr size_t get_page_size() { return 1 << get_page_size_log2(); }
|
||||
}
|
||||
/* base-internal includes */
|
||||
#include <base/internal/page_size.h>
|
||||
|
||||
#endif /* _CORE__INCLUDE__UTIL_H_ */
|
||||
|
@ -17,9 +17,6 @@
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Pd_session_component::bind_thread(Thread_capability) { }
|
||||
|
||||
|
||||
void Pd_session_component::assign_parent(Capability<Parent> parent)
|
||||
{
|
||||
_parent = parent;
|
||||
|
@ -74,7 +74,8 @@ Platform_thread::Registry *Platform_thread::_registry()
|
||||
** Platform_thread **
|
||||
*********************/
|
||||
|
||||
Platform_thread::Platform_thread(size_t, const char *name, unsigned, addr_t)
|
||||
Platform_thread::Platform_thread(size_t, const char *name, unsigned,
|
||||
Affinity::Location, addr_t)
|
||||
: _tid(-1), _pid(-1)
|
||||
{
|
||||
strncpy(_name, name, min(sizeof(_name), strlen(name) + 1));
|
||||
|
@ -67,11 +67,6 @@ class Stack_area_region_map : public Genode::Region_map
|
||||
void detach(Local_addr local_addr) {
|
||||
PWRN("stack area detach from 0x%p - not implemented", (void *)local_addr); }
|
||||
|
||||
Genode::Pager_capability add_client(Genode::Thread_capability) {
|
||||
return Genode::Pager_capability(); }
|
||||
|
||||
void remove_client(Genode::Pager_capability) { }
|
||||
|
||||
void fault_handler(Genode::Signal_context_capability) { }
|
||||
|
||||
State state() { return State(); }
|
||||
|
@ -45,10 +45,12 @@ struct Genode::Expanding_cpu_session_client
|
||||
Expanding_cpu_session_client(Genode::Capability<Cpu_session> cap)
|
||||
: Upgradeable_client<Genode::Cpu_session_client>(cap) { }
|
||||
|
||||
Thread_capability create_thread(size_t weight, Name const &name, addr_t utcb)
|
||||
Thread_capability create_thread(Pd_session_capability pd, size_t weight,
|
||||
Name const &name, Affinity::Location affinity,
|
||||
addr_t utcb)
|
||||
{
|
||||
return retry<Cpu_session::Out_of_metadata>(
|
||||
[&] () { return Cpu_session_client::create_thread(weight, name, utcb); },
|
||||
[&] () { return Cpu_session_client::create_thread(pd, weight, name, affinity, utcb); },
|
||||
[&] () { upgrade_ram(8*1024); });
|
||||
}
|
||||
};
|
||||
@ -280,11 +282,6 @@ class Genode::Platform_env_base : public Env
|
||||
|
||||
void detach(Local_addr local_addr);
|
||||
|
||||
Pager_capability add_client(Thread_capability thread) {
|
||||
return Pager_capability(); }
|
||||
|
||||
void remove_client(Pager_capability pager) { }
|
||||
|
||||
void fault_handler(Signal_context_capability handler) { }
|
||||
|
||||
State state() { return State(); }
|
||||
|
@ -452,7 +452,7 @@ Native_thread &Thread_base::native_thread() { return *_native_thread; }
|
||||
|
||||
|
||||
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||
Type type, Cpu_session * cpu_sess)
|
||||
Type type, Cpu_session * cpu_sess, Affinity::Location)
|
||||
: _cpu_session(cpu_sess)
|
||||
{
|
||||
Native_thread::Meta_data *meta_data =
|
||||
@ -470,7 +470,7 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||
|
||||
native_thread().meta_data->wait_for_construction();
|
||||
|
||||
_thread_cap = _cpu_session->create_thread(weight, name);
|
||||
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), weight, name);
|
||||
|
||||
Linux_native_cpu_client native_cpu(_cpu_session->native_cpu());
|
||||
native_cpu.thread_id(_thread_cap, native_thread().pid, native_thread().tid);
|
||||
@ -478,7 +478,7 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||
|
||||
|
||||
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||
Type type)
|
||||
Type type, Affinity::Location)
|
||||
: Thread_base(weight, name, stack_size, type, env()->cpu_session()) { }
|
||||
|
||||
void Thread_base::cancel_blocking()
|
||||
|
Reference in New Issue
Block a user