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

@ -17,12 +17,12 @@
enum { STACK_SIZE = 4096 };
struct Thread : Genode::Thread<STACK_SIZE>
struct Thread : Genode::Thread_deprecated<STACK_SIZE>
{
Genode::Lock &_barrier;
Thread(Genode::Lock &barrier)
: Genode::Thread<STACK_SIZE>("stat"), _barrier(barrier) { start(); }
: Genode::Thread_deprecated<STACK_SIZE>("stat"), _barrier(barrier) { start(); }
void entry()
{

View File

@ -34,11 +34,11 @@ static void *pthread_entry(void *)
PINF("first message");
/*
* Without the lazy initialization of 'Thread_base' objects for threads
* Without the lazy initialization of 'Thread' objects for threads
* created w/o Genode's Thread API, the printing of the first message will
* never return because the IPC reply could not be delivered.
*
* With the on-demand creation of 'Thread_base' objects, the second message
* With the on-demand creation of 'Thread' objects, the second message
* will appear in the LOG output.
*/

View File

@ -44,7 +44,7 @@ int main()
using namespace Genode;
/* activate for early printf in Rm_session_mmap::attach() etc. */
if (0) Thread_base::trace("FOO");
if (0) Thread::trace("FOO");
/* induce initial heap expansion to remove RM noise */
if (1) {