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

@@ -45,12 +45,12 @@ inline void Vmm::printf(const char *format, ...)
Lock::Guard guard(lock);
utcb_backup = *(Utcb_backup *)Thread_base::myself()->utcb();
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
Genode::printf("VMM: ");
Genode::vprintf(format, list);
*(Utcb_backup *)Thread_base::myself()->utcb() = utcb_backup;
*(Utcb_backup *)Thread::myself()->utcb() = utcb_backup;
va_end(list);
}

View File

@@ -43,7 +43,7 @@ class Vmm::Utcb_guard
Utcb_guard(Utcb_backup &backup_utcb) : _backup_utcb(backup_utcb)
{
Nova::Utcb *utcb =
reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb());
reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb());
unsigned header_len = (char *)utcb->msg - (char *)utcb;
unsigned len = header_len + utcb->msg_words() * sizeof(Nova::mword_t);
@@ -59,7 +59,7 @@ class Vmm::Utcb_guard
unsigned header_len = (char *)utcb->msg - (char *)utcb;
unsigned len = header_len + utcb->msg_words() * sizeof(Nova::mword_t);
Genode::memcpy(Thread_base::myself()->utcb(), utcb, len);
Genode::memcpy(Thread::myself()->utcb(), utcb, len);
}
};

View File

@@ -35,7 +35,7 @@ class Vmm::Vcpu_dispatcher : public T
{
private:
enum { WEIGHT = Genode::Cpu_session::DEFAULT_WEIGHT };
enum { WEIGHT = Genode::Cpu_session::Weight::DEFAULT_WEIGHT };
Pd_session &_pd;
Nova_native_pd_client _native_pd { _pd.native_pd() };
@@ -52,7 +52,7 @@ class Vmm::Vcpu_dispatcher : public T
static void _portal_entry()
{
/* obtain this pointer of the event handler */
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Thread *myself = Genode::Thread::myself();
DISPATCHER *vd = static_cast<DISPATCHER *>(myself);
vd->exit_reason = EV;
@@ -131,7 +131,7 @@ class Vmm::Vcpu_dispatcher : public T
}
/**
* Unused member of the 'Thread_base' interface
* Unused member of the 'Thread' interface
*
* Similarly to how 'Rpc_entrypoints' are handled, a 'Vcpu_dispatcher'
* comes with a custom initialization procedure, which does not call

View File

@@ -67,9 +67,9 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
{
using namespace Genode;
enum { WEIGHT = Cpu_session::DEFAULT_WEIGHT };
Thread_capability vcpu_vm =
_cpu_session->create_thread(_pd_session, WEIGHT, "vCPU", _location);
_cpu_session->create_thread(_pd_session, "vCPU",
_location, Cpu_session::Weight());
/* tell parent that this will be a vCPU */
Thread_state state;
@@ -104,16 +104,16 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
};
class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread
{
enum { WEIGHT = Genode::Cpu_session::DEFAULT_WEIGHT };
enum { WEIGHT = Genode::Cpu_session::Weight::DEFAULT_WEIGHT };
public:
Vcpu_same_pd(size_t stack_size, Cpu_session * cpu_session,
Genode::Affinity::Location location)
:
Thread_base(WEIGHT, "vCPU", stack_size, Type::NORMAL, cpu_session, location)
Thread(WEIGHT, "vCPU", stack_size, Type::NORMAL, cpu_session, location)
{
/* release pre-allocated selectors of Thread */
Genode::cap_map()->remove(native_thread().exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2);
@@ -140,7 +140,7 @@ class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
void start(Genode::addr_t sel_ec)
{
this->Thread_base::start();
this->Thread::start();
/* obtain interface to NOVA-specific CPU session operations */
Nova_native_cpu_client native_cpu(_cpu_session->native_cpu());