Thread API cleanup

This patch cleans up the thread API and comes with the following
noteworthy changes:

- Introduced Cpu_session::Weight type that replaces a formerly used
  plain integer value to prevent the accidental mix-up of
  arguments.
- The enum definition of Cpu_session::DEFAULT_WEIGHT moved to
  Cpu_session::Weight::DEFAULT_WEIGHT
- New Thread constructor that takes a 'Env &' as first argument.
  The original constructors are now marked as deprecated. For the
  common use case where the default 'Weight' and 'Affinity' are
  used, a shortcut is provided. In the long term, those two
  constructors should be the only ones to remain.
- The former 'Thread<>' class template has been renamed to
  'Thread_deprecated'.
- The former 'Thread_base' class is now called 'Thread'.
- The new 'name()' accessor returns the thread's name as 'Name'
  object as centrally defined via 'Cpu_session::Name'. It is meant to
  replace the old-fashioned 'name' method that takes a buffer and size
  as arguments.
- Adaptation of the thread test to the new API

Issue #1954
This commit is contained in:
Norman Feske
2016-05-04 12:27:17 +02:00
committed by Christian Helmuth
parent 7b73d1d823
commit fd401bdf53
211 changed files with 980 additions and 843 deletions

View File

@@ -122,7 +122,7 @@ Capability_space::create_rpc_obj_cap(Native_capability ep_cap,
** Implementation of the Capability_space interface **
******************************************************/
Native_capability Capability_space::create_ep_cap(Thread_base &ep_thread)
Native_capability Capability_space::create_ep_cap(Thread &ep_thread)
{
Cap_sel const ep_sel(ep_thread.native_thread().ep_sel);

View File

@@ -44,7 +44,7 @@ void Irq_object::entry()
Irq_object::Irq_object(unsigned irq)
:
Thread<4096>("irq"),
Thread_deprecated<4096>("irq"),
_sync_ack(Lock::LOCKED), _sync_bootup(Lock::LOCKED),
_irq(irq)
{ }

View File

@@ -74,11 +74,11 @@ void Ipc_pager::reply_and_wait_for_fault()
seL4_MessageInfo_t const reply_msg = seL4_MessageInfo_new(0, 0, 0, 0);
page_fault_msg_info =
seL4_ReplyRecv(Thread_base::myself()->native_thread().ep_sel, reply_msg, &badge);
seL4_ReplyRecv(Thread::myself()->native_thread().ep_sel, reply_msg, &badge);
} else {
page_fault_msg_info =
seL4_Recv(Thread_base::myself()->native_thread().ep_sel, &badge);
seL4_Recv(Thread::myself()->native_thread().ep_sel, &badge);
}
Fault_info const fault_info(page_fault_msg_info);

View File

@@ -137,7 +137,7 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
/*
* Populate the thread's IPC buffer with initial information about the
* thread. Once started, the thread picks up this information in the
* 'Thread_base::_thread_bootstrap' method.
* 'Thread::_thread_bootstrap' method.
*/
prepopulate_ipc_buffer(_info.ipc_buffer_phys, _ep_sel);

View File

@@ -27,7 +27,7 @@
using namespace Genode;
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
addr_t const utcb_virt_addr = (addr_t)&_stack->utcb();
@@ -57,29 +57,29 @@ void Thread_base::_init_platform_thread(size_t, Type type)
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
PDBG("not implemented");
}
void Thread_base::_thread_start()
void Thread::_thread_start()
{
Thread_base::myself()->_thread_bootstrap();
Thread_base::myself()->entry();
Thread::myself()->_thread_bootstrap();
Thread::myself()->entry();
sleep_forever();
}
void Thread_base::start()
void Thread::start()
{
start_sel4_thread(Cap_sel(native_thread().tcb_sel), (addr_t)&_thread_start,
(addr_t)stack_top());
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
PWRN("not implemented");
}

View File

@@ -31,7 +31,7 @@ namespace Genode { namespace Capability_space {
/**
* Create capability for RPC entrypoint thread
*/
Native_capability create_ep_cap(Thread_base &ep_thread);
Native_capability create_ep_cap(Thread &ep_thread);
/**
* Increment reference counter

View File

@@ -34,7 +34,7 @@ static inline void kernel_debugger_panic(char const *msg)
{
kernel_debugger_outstring(msg);
kernel_debugger_outstring("\n");
seL4_TCB_Suspend(Genode::Thread_base::myself()->native_thread().tcb_sel);
seL4_TCB_Suspend(Genode::Thread::myself()->native_thread().tcb_sel);
}
#endif /* _INCLUDE__BASE__INTERNAL__KERNEL_DEBUGGER_H_ */

View File

@@ -93,7 +93,7 @@ namespace {
** Implementation of the Capability_space interface **
******************************************************/
Native_capability Capability_space::create_ep_cap(Thread_base &ep_thread)
Native_capability Capability_space::create_ep_cap(Thread &ep_thread)
{
Cap_sel const ep_sel = Cap_sel(ep_thread.native_thread().ep_sel);

View File

@@ -47,12 +47,12 @@ static unsigned &rcv_sel()
{
/*
* When the function is called at the very early initialization phase, we
* cannot access Thread_base::myself()->native_thread() because the
* Thread_base object of the main thread does not exist yet. During this
* cannot access Thread::myself()->native_thread() because the
* Thread object of the main thread does not exist yet. During this
* phase, we return a reference to the 'main_rcv_sel' variable.
*/
if (Thread_base::myself()) {
return Thread_base::myself()->native_thread().rcv_sel;
if (Thread::myself()) {
return Thread::myself()->native_thread().rcv_sel;
}
static unsigned main_rcv_sel = Capability_space::alloc_rcv_sel();
@@ -313,7 +313,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
if (exc.value == Rpc_exception_code::INVALID_OBJECT) {
seL4_MessageInfo_t const request_msg_info =
seL4_Recv(Thread_base::myself()->native_thread().ep_sel, &badge);
seL4_Recv(Thread::myself()->native_thread().ep_sel, &badge);
decode_seL4_message(request_msg_info, request_msg);
@@ -324,7 +324,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
seL4_SetMR(MR_IDX_EXC_CODE, exc.value);
seL4_MessageInfo_t const request_msg_info =
seL4_ReplyRecv(Thread_base::myself()->native_thread().ep_sel,
seL4_ReplyRecv(Thread::myself()->native_thread().ep_sel,
reply_msg_info, &badge);
decode_seL4_message(request_msg_info, request_msg);
@@ -336,7 +336,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Ipc_server::Ipc_server()
:
Native_capability(Capability_space::create_ep_cap(*Thread_base::myself()))
Native_capability(Capability_space::create_ep_cap(*Thread::myself()))
{ }

View File

@@ -28,11 +28,11 @@ void prepare_init_main_thread() { }
void prepare_reinit_main_thread() { prepare_init_main_thread(); }
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
void Genode::Thread_base::_thread_bootstrap()
void Genode::Thread::_thread_bootstrap()
{
if (native_thread().ep_sel == 0) {
native_thread().ep_sel = _stack->utcb().ep_sel;

View File

@@ -19,6 +19,6 @@
using namespace Genode;
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
}

View File

@@ -24,38 +24,29 @@
using namespace Genode;
/**
* Entry point entered by new threads
*/
//void Thread_base::_thread_start()
//{
// PDBG("not implemented");
//}
/************
** Thread **
************/
/*****************
** Thread base **
*****************/
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
PDBG("not implemented");
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
PDBG("not implemented");
}
void Thread_base::start()
void Thread::start()
{
PDBG("not implemented");
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
PDBG("not implemented");
}