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

@ -21,7 +21,7 @@
extern "C" int wpa_main(void);
extern "C" void wpa_conf_reload(void);
class Wpa_thread : public Genode::Thread<8 * 1024 * sizeof(long)>
class Wpa_thread : public Genode::Thread_deprecated<8 * 1024 * sizeof(long)>
{
private:
@ -31,7 +31,7 @@ class Wpa_thread : public Genode::Thread<8 * 1024 * sizeof(long)>
public:
Wpa_thread(Genode::Lock &lock)
: Thread("wpa_supplicant"), _lock(lock), _exit(-1) { }
: Thread_deprecated("wpa_supplicant"), _lock(lock), _exit(-1) { }
void entry()
{

View File

@ -83,7 +83,7 @@ class Lx::Scheduler
return _ansi_esc_black();
}
struct Logger : Genode::Thread<0x4000>
struct Logger : Genode::Thread_deprecated<0x4000>
{
Timer::Connection _timer;
Lx::Scheduler &_scheduler;
@ -91,7 +91,7 @@ class Lx::Scheduler
Logger(Lx::Scheduler &scheduler, unsigned interval_seconds)
:
Genode::Thread<0x4000>("logger"),
Genode::Thread_deprecated<0x4000>("logger"),
_scheduler(scheduler), _interval(interval_seconds)
{
start();
@ -223,7 +223,7 @@ Lx::Task::Task(void (*func)(void*), void *arg, char const *name,
void Lx::Task::_deinit()
{
if (_stack)
Genode::Thread_base::myself()->free_secondary_stack(_stack);
Genode::Thread::myself()->free_secondary_stack(_stack);
}

View File

@ -203,7 +203,7 @@ class Lx::Task : public Lx::List<Lx::Task>::Element
if (_state == STATE_INIT) {
/* setup execution environment and call task's function */
_state = STATE_RUNNING;
Genode::Thread_base *th = Genode::Thread_base::myself();
Genode::Thread *th = Genode::Thread::myself();
enum { STACK_SIZE = 32 * 1024 }; /* FIXME make stack size configurable */
_stack = th->alloc_secondary_stack(_name, STACK_SIZE);

View File

@ -708,7 +708,7 @@ static void create_event(char const *fmt, va_list list)
Trace::Timestamp now = Trace::timestamp();
Genode::snprintf(event, sizeof(event), "delta = %llu ms %s",
(now - last) / 2260000, buf);
Thread_base::trace(event);
Thread::trace(event);
last = now;
}

View File

@ -112,7 +112,7 @@ namespace Net
class Net::Socketcall : public Genode::Signal_dispatcher_base,
public Genode::Signal_context_capability,
public Lxip::Socketcall,
public Genode::Thread<64 * 1024 * sizeof(Genode::addr_t)>
public Genode::Thread_deprecated<64 * 1024 * sizeof(Genode::addr_t)>
{
private:
@ -384,7 +384,7 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
public:
Socketcall()
: Thread("socketcall"),
: Thread_deprecated("socketcall"),
_signal(Genode::Signal_context_capability(Env::receiver()->manage(this)))
{
start();

View File

@ -62,7 +62,7 @@ class Routine : public Genode::List<Routine>::Element
/* will never return */
if (!_started) {
_started = true;
Genode::Thread_base *th = Genode::Thread_base::myself();
Genode::Thread *th = Genode::Thread::myself();
_stack = (char *) th->alloc_secondary_stack(_name, STACK_SIZE);
if (verbose)
@ -121,7 +121,7 @@ class Routine : public Genode::List<Routine>::Element
~Routine()
{
if (_stack)
Genode::Thread_base::myself()->free_secondary_stack(_stack);
Genode::Thread::myself()->free_secondary_stack(_stack);
}
/**

View File

@ -62,7 +62,7 @@ bool Lx::Task::run()
if (_state == STATE_INIT) {
/* setup execution environment and call task's function */
_state = STATE_RUNNING;
Genode::Thread_base *th = Genode::Thread_base::myself();
Genode::Thread *th = Genode::Thread::myself();
enum { STACK_SIZE = 32 * 1024 }; /* FIXME make stack size configurable */
_stack = th->alloc_secondary_stack(_name, STACK_SIZE);
@ -111,7 +111,7 @@ Lx::Task::~Task()
{
// scheduler.remove(this);
if (_stack)
Genode::Thread_base::myself()->free_secondary_stack(_stack);
Genode::Thread::myself()->free_secondary_stack(_stack);
}
@ -195,7 +195,7 @@ void Lx::Scheduler::schedule()
#include <timer_session/connection.h>
namespace {
struct Logger : Genode::Thread<0x4000>
struct Logger : Genode::Thread_deprecated<0x4000>
{
Timer::Connection _timer;
Lx::Scheduler &_scheduler;
@ -203,7 +203,7 @@ namespace {
Logger(Lx::Scheduler &scheduler, unsigned interval_seconds)
:
Genode::Thread<0x4000>("logger"),
Genode::Thread_deprecated<0x4000>("logger"),
_scheduler(scheduler), _interval(interval_seconds)
{
start();