mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 07:08:18 +00:00
Separation of thread operations from CPU session
This patch moves the thread operations from the 'Cpu_session' to the 'Cpu_thread' interface. A noteworthy semantic change is the meaning of the former 'exception_handler' function, which used to define both, the default exception handler or a thread-specific signal handler. Now, the 'Cpu_session::exception_sigh' function defines the CPU-session-wide default handler whereas the 'Cpu_thread::exception_sigh' function defines the thread-specific one. To retain the ability to create 'Child' objects without invoking a capability, the child's initial thread must be created outside the 'Child::Process'. It is now represented by the 'Child::Initial_thread', which is passed as argument to the 'Child' constructor. Fixes #1939
This commit is contained in:
committed by
Christian Helmuth
parent
59aec6114b
commit
a99989af40
@ -445,7 +445,7 @@ void Child::exit(int exit_value)
|
||||
|
||||
Thread_capability Child::main_thread_cap() const
|
||||
{
|
||||
return _process.initial_thread.cap;
|
||||
return _process.initial_thread.cap();
|
||||
}
|
||||
|
||||
|
||||
@ -482,7 +482,7 @@ Child::Child(Dataspace_capability elf_ds,
|
||||
Ram_session_capability ram_cap,
|
||||
Ram_session &ram,
|
||||
Cpu_session_capability cpu_cap,
|
||||
Cpu_session &cpu,
|
||||
Initial_thread_base &initial_thread,
|
||||
Region_map &local_rm,
|
||||
Region_map &remote_rm,
|
||||
Rpc_entrypoint &entrypoint,
|
||||
@ -500,8 +500,8 @@ try :
|
||||
_parent_cap(_entrypoint.manage(this)),
|
||||
_policy(policy),
|
||||
_server(_ram),
|
||||
_process(elf_ds, ldso_ds, pd_cap, pd, ram, cpu, local_rm, remote_rm,
|
||||
_parent_cap, policy.name())
|
||||
_process(elf_ds, ldso_ds, pd_cap, pd, ram, initial_thread, local_rm, remote_rm,
|
||||
_parent_cap)
|
||||
{ }
|
||||
catch (Cpu_session::Thread_creation_failed) { throw Process_startup_failed(); }
|
||||
catch (Cpu_session::Out_of_metadata) { throw Process_startup_failed(); }
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <base/child.h>
|
||||
#include <cpu_thread/client.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/elf.h>
|
||||
@ -162,18 +163,24 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds
|
||||
}
|
||||
|
||||
|
||||
Child::Process::Initial_thread::Initial_thread(Cpu_session &cpu,
|
||||
Pd_session_capability pd,
|
||||
char const *name)
|
||||
Child::Initial_thread::Initial_thread(Cpu_session &cpu,
|
||||
Pd_session_capability pd,
|
||||
Name const &name)
|
||||
:
|
||||
cpu(cpu),
|
||||
cap(cpu.create_thread(pd, name, Affinity::Location(), Cpu_session::Weight()))
|
||||
_cpu(cpu),
|
||||
_cap(cpu.create_thread(pd, name, Affinity::Location(), Cpu_session::Weight()))
|
||||
{ }
|
||||
|
||||
|
||||
Child::Process::Initial_thread::~Initial_thread()
|
||||
Child::Initial_thread::~Initial_thread()
|
||||
{
|
||||
cpu.kill_thread(cap);
|
||||
_cpu.kill_thread(_cap);
|
||||
}
|
||||
|
||||
|
||||
void Child::Initial_thread::start(addr_t ip)
|
||||
{
|
||||
Cpu_thread_client(_cap).start(ip, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -182,13 +189,12 @@ Child::Process::Process(Dataspace_capability elf_ds,
|
||||
Pd_session_capability pd_cap,
|
||||
Pd_session &pd,
|
||||
Ram_session &ram,
|
||||
Cpu_session &cpu,
|
||||
Initial_thread_base &initial_thread,
|
||||
Region_map &local_rm,
|
||||
Region_map &remote_rm,
|
||||
Parent_capability parent_cap,
|
||||
char const *name)
|
||||
Parent_capability parent_cap)
|
||||
:
|
||||
initial_thread(cpu, pd_cap, name),
|
||||
initial_thread(initial_thread),
|
||||
loaded_executable(elf_ds, ldso_ds, ram, local_rm, remote_rm, parent_cap)
|
||||
{
|
||||
/* register parent interface for new protection domain */
|
||||
@ -203,10 +209,7 @@ Child::Process::Process(Dataspace_capability elf_ds,
|
||||
return;
|
||||
|
||||
/* start main thread */
|
||||
if (cpu.start(initial_thread.cap, loaded_executable.entry, 0)) {
|
||||
PERR("start of initial thread failed");
|
||||
throw Cpu_session::Thread_creation_failed();
|
||||
}
|
||||
initial_thread.start(loaded_executable.entry);
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/env.h>
|
||||
#include <cpu_thread/client.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/stack.h>
|
||||
@ -62,11 +63,11 @@ void Thread::start()
|
||||
throw Cpu_session::Thread_creation_failed();
|
||||
|
||||
/* start execution at initial instruction pointer and stack pointer */
|
||||
_cpu_session->start(_thread_cap, (addr_t)_thread_start, _stack->top());
|
||||
Cpu_thread_client(_thread_cap).start((addr_t)_thread_start, _stack->top());
|
||||
}
|
||||
|
||||
|
||||
void Thread::cancel_blocking()
|
||||
{
|
||||
_cpu_session->cancel_blocking(_thread_cap);
|
||||
Cpu_thread_client(_thread_cap).cancel_blocking();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <base/trace/policy.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <util/construct_at.h>
|
||||
#include <cpu_thread/client.h>
|
||||
|
||||
/* local includes */
|
||||
#include <base/internal/trace_control.h>
|
||||
@ -74,7 +75,7 @@ bool Trace::Logger::_evaluate_control()
|
||||
Control::Inhibit_guard guard(*control);
|
||||
|
||||
/* obtain policy */
|
||||
Dataspace_capability policy_ds = cpu->trace_policy(thread_cap);
|
||||
Dataspace_capability policy_ds = Cpu_thread_client(thread_cap).trace_policy();
|
||||
|
||||
if (!policy_ds.valid()) {
|
||||
PWRN("could not obtain trace policy");
|
||||
@ -100,7 +101,7 @@ bool Trace::Logger::_evaluate_control()
|
||||
|
||||
/* obtain buffer */
|
||||
buffer = 0;
|
||||
Dataspace_capability buffer_ds = cpu->trace_buffer(thread_cap);
|
||||
Dataspace_capability buffer_ds = Cpu_thread_client(thread_cap).trace_buffer();
|
||||
|
||||
if (!buffer_ds.valid()) {
|
||||
PWRN("could not obtain trace buffer");
|
||||
@ -139,7 +140,7 @@ void Trace::Logger::init(Thread_capability thread, Cpu_session *cpu_session,
|
||||
thread_cap = thread;
|
||||
cpu = cpu_session;
|
||||
|
||||
unsigned const index = cpu->trace_control_index(thread);
|
||||
unsigned const index = Cpu_thread_client(thread).trace_control_index();
|
||||
Dataspace_capability ds = cpu->trace_control();
|
||||
size_t size = Dataspace_client(ds).size();
|
||||
if ((index + 1)*sizeof(Trace::Control) > size) {
|
||||
|
Reference in New Issue
Block a user