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

@ -323,7 +323,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Msgbuf_base &reply_msg,
Msgbuf_base &request_msg)
{
Receive_window &rcv_window = Thread_base::myself()->native_thread().rcv_window;
Receive_window &rcv_window = Thread::myself()->native_thread().rcv_window;
for (;;) {
@ -371,7 +371,7 @@ Ipc_server::Ipc_server()
:
Native_capability((Cap_index*)Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE])
{
Thread_base::myself()->native_thread().rcv_window.init();
Thread::myself()->native_thread().rcv_window.init();
}

View File

@ -41,19 +41,19 @@ void prepare_reinit_main_thread()
}
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
void Genode::Thread_base::_thread_bootstrap() { }
void Genode::Thread::_thread_bootstrap() { }
void Genode::Thread_base::_thread_start()
void Genode::Thread::_thread_start()
{
using namespace Genode;
Thread_base::myself()->_thread_bootstrap();
Thread_base::myself()->entry();
Thread_base::myself()->_join_lock.unlock();
Thread::myself()->_thread_bootstrap();
Thread::myself()->entry();
Thread::myself()->_join_lock.unlock();
sleep_forever();
}

View File

@ -14,11 +14,11 @@
#include <base/thread.h>
Genode::Thread_base *Genode::Thread_base::myself()
Genode::Thread *Genode::Thread::myself()
{
using namespace Fiasco;
return reinterpret_cast<Thread_base*>(l4_utcb_tcr()->user[UTCB_TCR_THREAD_OBJ]);
return reinterpret_cast<Thread*>(l4_utcb_tcr()->user[UTCB_TCR_THREAD_OBJ]);
}

View File

@ -29,7 +29,7 @@ namespace Fiasco {
using namespace Genode;
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
using namespace Fiasco;
@ -41,7 +41,7 @@ void Thread_base::_deinit_platform_thread()
}
void Thread_base::_init_platform_thread(size_t weight, Type type)
void Thread::_init_platform_thread(size_t weight, Type type)
{
/* if no cpu session is given, use it from the environment */
if (!_cpu_session)
@ -50,10 +50,8 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
if (type == NORMAL)
{
/* create thread at core */
char buf[48];
name(buf, sizeof(buf));
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(),
weight, buf);
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), name(),
Location(), Weight(weight));
/* assign thread to protection domain */
if (!_thread_cap.valid())
@ -74,7 +72,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
}
void Thread_base::start()
void Thread::start()
{
using namespace Fiasco;
@ -98,7 +96,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
_cpu_session->cancel_blocking(_thread_cap);
}