mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 22:28:18 +00:00
Remove exceptions from Cpu_session interface
The 'Thread_creation_failed' error is now reflected as 'Thread::Start_result' return value. This change also removes the use of 'Invalid_thread' within core as this exception is an alias of Cpu_session::Thread_creation_failed. Issue #5245
This commit is contained in:
@ -43,7 +43,7 @@ class Core::Irq_object : public Thread
|
||||
void sigh(Signal_context_capability cap);
|
||||
void ack_irq();
|
||||
|
||||
void start() override;
|
||||
Start_result start() override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -75,9 +75,10 @@ void Irq_object::ack_irq()
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::start()
|
||||
Thread::Start_result Irq_object::start()
|
||||
{
|
||||
warning(__func__, " not implemented");
|
||||
return Start_result::DENIED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,10 +110,11 @@ void Irq_object::ack_irq()
|
||||
}
|
||||
|
||||
|
||||
void Irq_object::start()
|
||||
Thread::Start_result Irq_object::start()
|
||||
{
|
||||
Thread::start();
|
||||
Start_result const result = Thread::start();
|
||||
_sync_bootup.block();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,8 +64,9 @@ void Thread::_init_platform_thread(size_t, Type) { }
|
||||
void Thread::_deinit_platform_thread() { }
|
||||
|
||||
|
||||
void Thread::start()
|
||||
Thread::Start_result Thread::start()
|
||||
{
|
||||
native_thread().tid = lx_create_thread(Thread::_thread_start, stack_top());
|
||||
native_thread().pid = lx_getpid();
|
||||
return Start_result::OK;
|
||||
}
|
||||
|
@ -24,6 +24,16 @@
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
static Thread_capability create_thread(auto &pd, auto &cpu, auto const &name)
|
||||
{
|
||||
return cpu.create_thread(pd, name, { }, { }).template convert<Thread_capability>(
|
||||
[&] (Thread_capability cap) { return cap; },
|
||||
[&] (Cpu_session::Create_thread_error) {
|
||||
error("failed to create thread via CPU session");
|
||||
return Thread_capability(); });
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Register main thread at core
|
||||
*
|
||||
@ -35,8 +45,7 @@ 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(create_thread(pd, cpu, name))
|
||||
{ }
|
||||
|
||||
|
||||
|
@ -110,10 +110,12 @@ void Thread::_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(pd_session_cap(),
|
||||
_stack->name().string(),
|
||||
Affinity::Location(),
|
||||
Weight());
|
||||
_cpu_session->create_thread(pd_session_cap(), _stack->name().string(),
|
||||
Affinity::Location(), Weight()).with_result(
|
||||
[&] (Thread_capability cap) { _thread_cap = cap; },
|
||||
[&] (Cpu_session::Create_thread_error) {
|
||||
error("Thread::_init_platform_thread: create_thread failed");
|
||||
});
|
||||
return;
|
||||
}
|
||||
/* adjust initial object state for main threads */
|
||||
@ -152,11 +154,13 @@ void Thread::_deinit_platform_thread()
|
||||
}
|
||||
|
||||
/* inform core about the killed thread */
|
||||
_cpu_session->kill_thread(_thread_cap);
|
||||
_thread_cap.with_result(
|
||||
[&] (Thread_capability cap) { _cpu_session->kill_thread(cap); },
|
||||
[&] (Cpu_session::Create_thread_error) { });
|
||||
}
|
||||
|
||||
|
||||
void Thread::start()
|
||||
Thread::Start_result Thread::start()
|
||||
{
|
||||
/* synchronize calls of the 'start' function */
|
||||
static Mutex mutex;
|
||||
@ -181,6 +185,8 @@ void Thread::start()
|
||||
|
||||
/* wait until the 'thread_start' function got entered */
|
||||
startup_lock().block();
|
||||
|
||||
return Start_result::OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -493,12 +493,13 @@ Thread *Thread::myself()
|
||||
}
|
||||
|
||||
|
||||
void Thread::start()
|
||||
Thread::Start_result Thread::start()
|
||||
{
|
||||
/*
|
||||
* Unblock thread that is supposed to slumber in 'thread_start'.
|
||||
*/
|
||||
native_thread().meta_data->started();
|
||||
return Start_result::OK;
|
||||
}
|
||||
|
||||
|
||||
@ -531,9 +532,14 @@ Thread::Thread(size_t weight, const char *name, size_t /* stack size */,
|
||||
|
||||
_thread_cap = _cpu_session->create_thread(_env_ptr->pd_session_cap(), name,
|
||||
Location(), Weight(weight));
|
||||
|
||||
Linux_native_cpu_client native_cpu(_cpu_session->native_cpu());
|
||||
native_cpu.thread_id(_thread_cap, native_thread().pid, native_thread().tid);
|
||||
_thread_cap.with_result(
|
||||
[&] (Thread_capability cap) {
|
||||
Linux_native_cpu_client native_cpu(_cpu_session->native_cpu());
|
||||
native_cpu.thread_id(cap, native_thread().pid, native_thread().tid);
|
||||
},
|
||||
[&] (Cpu_session::Create_thread_error) {
|
||||
error("failed to create hybrid thread"); }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -573,7 +579,9 @@ Thread::~Thread()
|
||||
_native_thread = nullptr;
|
||||
|
||||
/* inform core about the killed thread */
|
||||
_cpu_session->kill_thread(_thread_cap);
|
||||
_thread_cap.with_result(
|
||||
[&] (Thread_capability cap) { _cpu_session->kill_thread(cap); },
|
||||
[&] (Cpu_session::Create_thread_error) { });
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user