core: tie Platform_thread to Platform_pd

This patch tightens the coupling of the 'Platform_thread' objects
with their corresponding 'Platform_pd' objects by specifying the
'Platform_pd' as constructor argument, keeping the relationship
as a reference (instead of a pointer), and constraining the
lifetime of 'Platform_pd' objects to the lifetime of the PD.

It thereby clears the way to simplify the thread creation since all
PD-related information (like quota budgets) are now known at the
construction time of the 'Platform_thread'.

The return value of 'Platform_thread::start' has been removed because it
is not evaluated by 'Cpu_thread_component'.

Related to #5256
This commit is contained in:
Norman Feske
2024-06-26 17:26:12 +02:00
parent c18f7c7594
commit d44ec53cd3
45 changed files with 628 additions and 1013 deletions

View File

@ -60,6 +60,7 @@ class Core::Platform_thread : Interface
Platform_pd *_platform_pd; /* protection domain thread is bound to */
Pager_object *_pager_obj;
unsigned _prio;
bool _bound_to_pd = false;
Affinity::Location _location { };
@ -74,7 +75,7 @@ class Core::Platform_thread : Interface
/**
* Constructor for non-core threads
*/
Platform_thread(size_t, const char *name, unsigned priority,
Platform_thread(Platform_pd &, size_t, const char *name, unsigned priority,
Affinity::Location, addr_t);
/**
@ -93,16 +94,18 @@ class Core::Platform_thread : Interface
*/
~Platform_thread();
/**
* Return true if thread creation succeeded
*/
bool valid() const { return _bound_to_pd; }
/**
* Start thread
*
* \param ip instruction pointer to start at
* \param sp stack pointer to use
*
* \retval 0 successful
* \retval -1 thread could not be started
*/
int start(void *ip, void *sp);
void start(void *ip, void *sp);
/**
* Pause this thread

View File

@ -38,7 +38,7 @@ Trace::Execution_time Platform_thread::execution_time() const
}
int Platform_thread::start(void *ip, void *sp)
void Platform_thread::start(void *ip, void *sp)
{
if (!_platform_pd) {
@ -62,7 +62,7 @@ int Platform_thread::start(void *ip, void *sp)
if (l4_msgtag_has_error(tag)) {
warning("l4_thread_control_commit for ",
Hex(_thread.local.data()->kcap()), " failed!");
return -1;
return;
}
_state = RUNNING;
@ -72,10 +72,8 @@ int Platform_thread::start(void *ip, void *sp)
(l4_addr_t) sp, 0);
if (l4_msgtag_has_error(tag)) {
warning("l4_thread_ex_regs failed!");
return -1;
return;
}
return 0;
}
@ -280,7 +278,7 @@ void Platform_thread::_finalize_construction()
}
Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
Platform_thread::Platform_thread(Platform_pd &pd, size_t, const char *name, unsigned prio,
Affinity::Location location, addr_t)
:
_name(name),
@ -298,6 +296,7 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
_create_thread();
_finalize_construction();
affinity(location);
_bound_to_pd = pd.bind_thread(*this);
}