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

@ -81,7 +81,7 @@ void Irq_object::_wait_for_irq()
void Irq_object::start()
{
::Thread_base::start();
::Thread::start();
_sync_bootup.lock();
}
@ -115,7 +115,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

@ -25,16 +25,16 @@
using namespace Genode;
void Thread_base::_thread_start()
void Thread::_thread_start()
{
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();
}
void Thread_base::start()
void Thread::start()
{
/* create and start platform thread */
native_thread().pt = new(platform()->core_mem_alloc())
@ -49,7 +49,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
/*
* Within core, we never need to unblock threads
@ -57,7 +57,7 @@ void Thread_base::cancel_blocking()
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), native_thread().pt);

View File

@ -27,14 +27,14 @@ void prepare_init_main_thread() { }
void prepare_reinit_main_thread() { }
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
void Thread_base::_thread_bootstrap() { }
void Thread::_thread_bootstrap() { }
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) { return; }
_thread_cap = Genode::env()->parent()->main_thread_cap();

View File

@ -56,7 +56,7 @@ namespace Genode {
_sem = call<Rpc_request_semaphore>();
l4_msgtag_t tag = l4_irq_attach(_sem.dst(), 0,
Thread_base::myself()->native_thread().kcap);
Thread::myself()->native_thread().kcap);
if (l4_error(tag))
PERR("l4_irq_attach failed with %ld!", l4_error(tag));
}

View File

@ -43,11 +43,11 @@ using namespace Genode;
/**
* Dispatches interrupts from kernel
*/
class Genode::Interrupt_handler : public Thread<2048*sizeof(long)>
class Genode::Interrupt_handler : public Thread_deprecated<2048*sizeof(long)>
{
private:
Interrupt_handler() : Thread("irq_handler") { start(); }
Interrupt_handler() : Thread_deprecated("irq_handler") { start(); }
public:

View File

@ -151,7 +151,7 @@ Pager_capability Pager_entrypoint::manage(Pager_object *obj)
{
using namespace Fiasco;
Native_capability cap(_cap_factory.alloc(Thread_base::_thread_cap));
Native_capability cap(_cap_factory.alloc(Thread::_thread_cap));
/* add server object to object pool */
obj->cap(cap);

View File

@ -31,16 +31,16 @@ namespace Fiasco {
using namespace Genode;
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
PWRN("%s: not implemented yet!", __func__);
}
void Thread_base::_init_platform_thread(size_t, Type) { }
void Thread::_init_platform_thread(size_t, Type) { }
void Thread_base::start()
void Thread::start()
{
using namespace Fiasco;
@ -68,7 +68,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
/*
* Within core, we never need to unblock threads

View File

@ -48,7 +48,7 @@ static inline void thread_yield() { Fiasco::l4_thread_yield(); }
*
* \return true if the thread was in blocking state
*/
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
{
Fiasco::l4_cap_idx_t tid = thread_base ?
thread_base->native_thread().kcap :
@ -62,7 +62,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
/**
* Yield CPU time to the specified thread
*/
static inline void thread_switch_to(Genode::Thread_base *thread_base)
static inline void thread_switch_to(Genode::Thread *thread_base)
{
Fiasco::l4_cap_idx_t tid = thread_base ?
thread_base->native_thread().kcap :
@ -83,7 +83,7 @@ static void thread_stop_myself()
{
using namespace Fiasco;
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Thread *myself = Genode::Thread::myself();
Fiasco::l4_cap_idx_t tid = myself ?
myself->native_thread().kcap :
Fiasco::MAIN_THREAD_CAP;

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);
}

View File

@ -197,7 +197,7 @@ class Genode::Pager_object : public Object_pool<Pager_object>::Entry,
class Genode::Pager_entrypoint : public Object_pool<Pager_object>,
public Thread<PAGER_EP_STACK_SIZE>,
public Thread_deprecated<PAGER_EP_STACK_SIZE>,
public Kernel_object<Kernel::Signal_receiver>,
public Ipc_pager
{

View File

@ -17,7 +17,7 @@
/* core includes */
#include <kernel/thread_event.h>
namespace Kernel { class Thread_base; }
namespace Kernel { class Thread; }
/**
* Hardware specific base of kernel thread-objects

View File

@ -108,7 +108,7 @@ void Pager_entrypoint::dissolve(Pager_object * const o)
Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
: Thread<PAGER_EP_STACK_SIZE>("pager_ep"),
: Thread_deprecated<PAGER_EP_STACK_SIZE>("pager_ep"),
Kernel_object<Kernel::Signal_receiver>(true)
{ start(); }

View File

@ -167,7 +167,7 @@ int Platform_thread::start(void * const ip, void * const sp)
unsigned const cpu =
_location.valid() ? _location.xpos() : Cpu::primary_id();
Native_utcb * utcb = Thread_base::myself()->utcb();
Native_utcb * utcb = Thread::myself()->utcb();
/* reset capability counter */
utcb->cap_cnt(0);

View File

@ -48,7 +48,7 @@ void Pager_entrypoint::entry()
if (Kernel::await_signal(_cap.dst())) continue;
Untyped_capability cap =
(*(Pager_object**)Thread_base::myself()->utcb()->data())->cap();
(*(Pager_object**)Thread::myself()->utcb()->data())->cap();
/*
* Synchronize access and ensure that the object is still managed

View File

@ -34,7 +34,7 @@ namespace Genode { Rm_session *env_stack_area_rm_session(); }
namespace Hw { extern Untyped_capability _main_thread_cap; }
void Thread_base::start()
void Thread::start()
{
/* start thread with stack pointer at the top of stack */
if (native_thread().platform_thread->start((void *)&_thread_start, stack_top()))
@ -42,20 +42,20 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
native_thread().platform_thread->cancel_blocking();
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), native_thread().platform_thread);
}
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) {
native_thread().platform_thread = new (platform()->core_mem_alloc())

View File

@ -33,7 +33,7 @@ static inline void thread_yield() {
* Return kernel name of thread t
*/
static inline Kernel::capid_t
native_thread_id(Genode::Thread_base * const t)
native_thread_id(Genode::Thread * const t)
{
return t ? t->native_thread().cap.dst() : Hw::_main_thread_cap.dst();
}
@ -42,7 +42,7 @@ native_thread_id(Genode::Thread_base * const t)
/**
* Yield execution time-slice of current thread to thread t
*/
static inline void thread_switch_to(Genode::Thread_base * const t)
static inline void thread_switch_to(Genode::Thread * const t)
{
Kernel::yield_thread(native_thread_id(t));
}
@ -52,7 +52,7 @@ static inline void thread_switch_to(Genode::Thread_base * const t)
* Resume thread t and return wether t was paused or not
*/
static inline bool
thread_check_stopped_and_restart(Genode::Thread_base * const t)
thread_check_stopped_and_restart(Genode::Thread * const t)
{
return Kernel::resume_local_thread(native_thread_id(t));
}

View File

@ -94,12 +94,12 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
Msgbuf_base &snd_msg, Msgbuf_base &rcv_msg,
size_t rcv_caps)
{
Native_utcb &utcb = *Thread_base::myself()->utcb();
Native_utcb &utcb = *Thread::myself()->utcb();
retry<Genode::Allocator::Out_of_memory>(
[&] () {
copy_msg_to_utcb(snd_msg, *Thread_base::myself()->utcb());
copy_msg_to_utcb(snd_msg, *Thread::myself()->utcb());
switch (Kernel::send_request_msg(dst.dst(),
rcv_caps)) {
@ -123,7 +123,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc,
Msgbuf_base &snd_msg)
{
Native_utcb &utcb = *Thread_base::myself()->utcb();
Native_utcb &utcb = *Thread::myself()->utcb();
copy_msg_to_utcb(snd_msg, utcb);
utcb.exception_code(exc.value);
snd_msg.reset();
@ -136,7 +136,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
Msgbuf_base &reply_msg,
Msgbuf_base &request_msg)
{
Native_utcb &utcb = *Thread_base::myself()->utcb();
Native_utcb &utcb = *Thread::myself()->utcb();
retry<Genode::Allocator::Out_of_memory>(
[&] () {
@ -165,8 +165,8 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
Ipc_server::Ipc_server()
:
Native_capability(Thread_base::myself() ? Thread_base::myself()->native_thread().cap
: Hw::_main_thread_cap)
Native_capability(Thread::myself() ? Thread::myself()->native_thread().cap
: Hw::_main_thread_cap)
{ }

View File

@ -32,8 +32,8 @@ namespace Genode {
/*
* On base-hw, no signal thread is needed.
*/
void init_signal_thread() __attribute__((weak));
void init_signal_thread() { }
void init_signal_thread(Env &) __attribute__((weak));
void init_signal_thread(Env &) { }
void destroy_signal_thread() { }
}
@ -124,7 +124,7 @@ void Signal_receiver::block_for_signal()
return;
}
/* read signal data */
const void * const utcb = Thread_base::myself()->utcb()->data();
const void * const utcb = Thread::myself()->utcb()->data();
Signal::Data * const data = (Signal::Data *)utcb;
Signal_context * const context = data->context;
{

View File

@ -46,7 +46,7 @@ void prepare_init_main_thread()
* Make data from the startup info persistantly available by copying it
* before the UTCB gets polluted by the following function calls.
*/
Native_utcb * utcb = Thread_base::myself()->utcb();
Native_utcb * utcb = Thread::myself()->utcb();
_parent_cap = utcb->cap_get(Native_utcb::PARENT);
Untyped_capability ds_cap(utcb->cap_get(Native_utcb::UTCB_DATASPACE));
_main_thread_utcb_ds = reinterpret_cap_cast<Ram_dataspace>(ds_cap);
@ -57,24 +57,24 @@ void prepare_init_main_thread()
void prepare_reinit_main_thread() { prepare_init_main_thread(); }
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
Native_utcb *Thread_base::utcb()
Native_utcb *Thread::utcb()
{
if (this) { return &_stack->utcb(); }
return utcb_main_thread();
}
void Thread_base::_thread_start()
void Thread::_thread_start()
{
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();
Genode::sleep_forever();
}
void Thread_base::_thread_bootstrap() {
void Thread::_thread_bootstrap() {
native_thread().cap = myself()->utcb()->cap_get(Native_utcb::THREAD_MYSELF); }

View File

@ -30,21 +30,20 @@ namespace Hw {
extern Untyped_capability _main_thread_cap;
}
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
void Thread_base::_init_platform_thread(size_t weight, Type type)
void Thread::_init_platform_thread(size_t weight, Type type)
{
if (!_cpu_session) { _cpu_session = env()->cpu_session(); }
if (type == NORMAL) {
/* create server object */
char buf[48];
name(buf, sizeof(buf));
addr_t const utcb = (addr_t)&_stack->utcb();
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(),
weight, buf, _affinity, utcb);
name(), _affinity,
Weight(weight), utcb);
return;
}
/* if we got reinitialized we have to get rid of the old UTCB */
@ -67,7 +66,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
if (!_cpu_session)
_cpu_session = env()->cpu_session();
@ -82,7 +81,7 @@ void Thread_base::_deinit_platform_thread()
}
void Thread_base::start()
void Thread::start()
{
/* attach userland stack */
try {
@ -100,7 +99,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
_cpu_session->cancel_blocking(_thread_cap);
}

View File

@ -73,7 +73,7 @@ class Sync::Signal
}
};
class Counter : private Thread<2 * 1024 * sizeof(Genode::addr_t)>
class Counter : private Thread_deprecated<2 * 1024 * sizeof(Genode::addr_t)>
{
private:
@ -106,7 +106,7 @@ class Counter : private Thread<2 * 1024 * sizeof(Genode::addr_t)>
Counter(char const name, size_t const weight,
Sync::Session * const sync)
:
Thread(weight, "counter"), _name(name), _value(0) ,
Thread_deprecated(weight, "counter"), _name(name), _value(0) ,
_sync_sig(sync, SYNC_SIG), _stage(1)
{
Thread::start();

View File

@ -160,7 +160,7 @@ namespace Genode {
Socket_pair server_socket_pair()
{
return create_server_socket_pair(Thread_base::myself()->native_thread().tid);
return create_server_socket_pair(Thread::myself()->native_thread().tid);
}
void destroy_server_socket_pair(Socket_pair socket_pair)

View File

@ -28,7 +28,7 @@ static void empty_signal_handler(int) { }
static char signal_stack[0x2000] __attribute__((aligned(0x1000)));
void Thread_base::_thread_start()
void Thread::_thread_start()
{
lx_sigaltstack(signal_stack, sizeof(signal_stack));
@ -46,23 +46,23 @@ void Thread_base::_thread_start()
*/
lx_sigsetmask(LX_SIGCHLD, false);
Thread_base::myself()->entry();
Thread_base::myself()->_join_lock.unlock();
Thread::myself()->entry();
Thread::myself()->_join_lock.unlock();
sleep_forever();
}
void Thread_base::_init_platform_thread(size_t, Type) { }
void Thread::_init_platform_thread(size_t, Type) { }
void Thread_base::_deinit_platform_thread() { }
void Thread::_deinit_platform_thread() { }
void Thread_base::start()
void Thread::start()
{
native_thread().tid = lx_create_thread(Thread_base::_thread_start, stack_top(), this);
native_thread().tid = lx_create_thread(Thread::_thread_start, stack_top(), this);
native_thread().pid = lx_getpid();
}
void Thread_base::cancel_blocking() { }
void Thread::cancel_blocking() { }

View File

@ -38,7 +38,7 @@ static inline void thread_yield()
}
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
{
const int *futex_counter_ptr = thread_base ?
&thread_base->native_thread().futex_counter :
@ -47,7 +47,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
}
static inline void thread_switch_to(Genode::Thread_base *thread_base)
static inline void thread_switch_to(Genode::Thread *thread_base)
{
thread_yield();
}
@ -60,7 +60,7 @@ static inline void thread_stop_myself()
* 'thread_check_stopped_and_restart()' function will get called
* repeatedly until this thread has actually executed the syscall.
*/
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Thread *myself = Genode::Thread::myself();
const int *futex_counter_ptr = myself ?
&myself->native_thread().futex_counter :
&main_thread_futex_counter;

View File

@ -37,7 +37,7 @@ Child::Process::Initial_thread::Initial_thread(Cpu_session &cpu,
char const *name)
:
cpu(cpu),
cap(cpu.create_thread(pd, Cpu_session::DEFAULT_WEIGHT, name))
cap(cpu.create_thread(pd, name, Affinity::Location(), Cpu_session::Weight()))
{ }

View File

@ -431,7 +431,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
* Block infinitely if called from the main thread. This may happen if the
* main thread calls 'sleep_forever()'.
*/
if (!Thread_base::myself()) {
if (!Thread::myself()) {
struct timespec ts = { 1000, 0 };
for (;;) lx_nanosleep(&ts, 0);
}
@ -443,7 +443,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
msg.accept_sockets(Message::MAX_SDS_PER_MSG);
Native_thread &native_thread = Thread_base::myself()->native_thread();
Native_thread &native_thread = Thread::myself()->native_thread();
request_msg.reset();
int const ret = lx_recvmsg(native_thread.socket_pair.server_sd, msg.msg(), 0);
@ -479,10 +479,10 @@ Ipc_server::Ipc_server()
* definition, main is never an RPC entrypoint. However, the main thread
* may call 'sleep_forever()', which instantiates 'Ipc_server'.
*/
if (!Thread_base::myself())
if (!Thread::myself())
return;
Native_thread &native_thread = Thread_base::myself()->native_thread();
Native_thread &native_thread = Thread::myself()->native_thread();
if (native_thread.is_ipc_server) {
PRAW("[%d] unexpected multiple instantiation of Ipc_server by one thread",
@ -504,14 +504,14 @@ Ipc_server::Ipc_server()
Ipc_server::~Ipc_server()
{
if (!Thread_base::myself())
if (!Thread::myself())
return;
/*
* Reset thread role to non-server such that we can enter 'sleep_forever'
* without getting a warning.
*/
Native_thread &native_thread = Thread_base::myself()->native_thread();
Native_thread &native_thread = Thread::myself()->native_thread();
Genode::ep_sd_registry()->disassociate(native_thread.socket_pair.client_sd);
native_thread.is_ipc_server = false;

View File

@ -175,7 +175,7 @@ namespace Genode {
Socket_pair socket_pair;
Thread_base *thread = Thread_base::myself();
Thread *thread = Thread::myself();
if (thread) {
socket_pair.server_sd = native_cpu.server_sd(thread->cap()).dst().socket;
socket_pair.client_sd = native_cpu.client_sd(thread->cap()).dst().socket;

View File

@ -47,7 +47,7 @@ static void thread_exit_signal_handler(int) { lx_exit(0); }
static char signal_stack[0x2000] __attribute__((aligned(0x1000)));
void Thread_base::_thread_start()
void Thread::_thread_start()
{
lx_sigaltstack(signal_stack, sizeof(signal_stack));
@ -57,7 +57,7 @@ void Thread_base::_thread_start()
*/
lx_sigaction(LX_SIGUSR1, empty_signal_handler);
Thread_base * const thread = Thread_base::myself();
Thread * const thread = Thread::myself();
/* inform core about the new thread and process ID of the new thread */
Linux_native_cpu_client native_cpu(thread->_cpu_session->native_cpu());
@ -75,7 +75,7 @@ void Thread_base::_thread_start()
}
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)
@ -84,7 +84,9 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
/* for normal threads create an object at the CPU session */
if (type == NORMAL) {
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(),
weight, _stack->name().string());
_stack->name().string(),
Affinity::Location(),
Weight());
return;
}
/* adjust initial object state for main threads */
@ -93,7 +95,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
/*
* Kill thread until it is really really dead
@ -124,7 +126,7 @@ void Thread_base::_deinit_platform_thread()
}
void Thread_base::start()
void Thread::start()
{
/* synchronize calls of the 'start' function */
static Lock lock;
@ -142,7 +144,7 @@ void Thread_base::start()
threadlib_initialized = true;
}
native_thread().tid = lx_create_thread(Thread_base::_thread_start, stack_top(), this);
native_thread().tid = lx_create_thread(Thread::_thread_start, stack_top(), this);
native_thread().pid = lx_getpid();
/* wait until the 'thread_start' function got entered */
@ -150,7 +152,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
_cpu_session->cancel_blocking(_thread_cap);
}

View File

@ -194,7 +194,7 @@ namespace Genode {
* Filled out by 'thread_start' function in the stack of the new
* thread
*/
Thread_base * const thread_base;
Thread * const thread_base;
/**
* POSIX thread handle
@ -204,9 +204,9 @@ namespace Genode {
/**
* Constructor
*
* \param thread associated 'Thread_base' object
* \param thread associated 'Thread' object
*/
Meta_data(Thread_base *thread) : thread_base(thread)
Meta_data(Thread *thread) : thread_base(thread)
{
native_thread.meta_data = this;
}
@ -261,7 +261,7 @@ namespace Genode {
public:
Thread_meta_data_created(Thread_base *thread)
Thread_meta_data_created(Thread *thread)
: Native_thread::Meta_data(thread) { }
void wait_for_construction()
@ -302,7 +302,7 @@ namespace Genode {
{
public:
Thread_meta_data_adopted(Thread_base *thread)
Thread_meta_data_adopted(Thread *thread)
: Native_thread::Meta_data(thread) { }
void wait_for_construction()
@ -374,13 +374,13 @@ static void *thread_start(void *arg)
adopt_thread(meta_data);
/* unblock 'Thread_base' constructor */
/* unblock 'Thread' constructor */
meta_data->constructed();
/* block until the 'Thread_base::start' gets called */
/* block until the 'Thread::start' gets called */
meta_data->wait_for_start();
Thread_base::myself()->entry();
Thread::myself()->entry();
meta_data->joined();
return 0;
@ -390,7 +390,7 @@ static void *thread_start(void *arg)
extern "C" void *malloc(::size_t size);
Thread_base *Thread_base::myself()
Thread *Thread::myself()
{
void * const tls = pthread_getspecific(tls_key());
@ -406,26 +406,26 @@ Thread_base *Thread_base::myself()
* Genode's thread API. This may happen if a native Linux library creates
* threads via the pthread library. If such a thread calls Genode code,
* which then tries to perform IPC, the program fails because there exists
* no 'Thread_base' object. We recover from this unfortunate situation by
* creating a dummy 'Thread_base' object and associate it with the calling
* no 'Thread' object. We recover from this unfortunate situation by
* creating a dummy 'Thread' object and associate it with the calling
* thread.
*/
/*
* Create dummy 'Thread_base' object but suppress the execution of its
* Create dummy 'Thread' object but suppress the execution of its
* constructor. If we called the constructor, we would create a new Genode
* thread, which is not what we want. For the allocation, we use glibc
* malloc because 'Genode::env()->heap()->alloc()' uses IPC.
*
* XXX Both the 'Thread_base' and 'Native_thread::Meta_data' objects are
* XXX Both the 'Thread' and 'Native_thread::Meta_data' objects are
* never freed.
*/
Thread_base *thread = (Thread_base *)malloc(sizeof(Thread_base));
Thread *thread = (Thread *)malloc(sizeof(Thread));
memset(thread, 0, sizeof(*thread));
Native_thread::Meta_data *meta_data = new Thread_meta_data_adopted(thread);
/*
* Initialize 'Thread_base::_native_thread' to point to the default-
* Initialize 'Thread::_native_thread' to point to the default-
* constructed 'Native_thread' (part of 'Meta_data').
*/
meta_data->thread_base->_native_thread = &meta_data->native_thread;
@ -435,7 +435,7 @@ Thread_base *Thread_base::myself()
}
void Thread_base::start()
void Thread::start()
{
/*
* Unblock thread that is supposed to slumber in 'thread_start'.
@ -444,17 +444,17 @@ void Thread_base::start()
}
void Thread_base::join()
void Thread::join()
{
native_thread().meta_data->wait_for_join();
}
Native_thread &Thread_base::native_thread() { return *_native_thread; }
Native_thread &Thread::native_thread() { return *_native_thread; }
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session * cpu_sess, Affinity::Location)
Thread::Thread(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session * cpu_sess, Affinity::Location)
: _cpu_session(cpu_sess)
{
Native_thread::Meta_data *meta_data =
@ -472,18 +472,31 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
native_thread().meta_data->wait_for_construction();
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), weight, name);
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), name,
Location(), Weight(weight));
Linux_native_cpu_client native_cpu(_cpu_session->native_cpu());
native_cpu.thread_id(_thread_cap, native_thread().pid, native_thread().tid);
}
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Affinity::Location)
: Thread_base(weight, name, stack_size, type, env()->cpu_session()) { }
Thread::Thread(size_t weight, const char *name, size_t stack_size,
Type type, Affinity::Location)
: Thread(weight, name, stack_size, type, env()->cpu_session()) { }
void Thread_base::cancel_blocking()
Thread::Thread(Env &env, Name const &name, size_t stack_size, Location location,
Weight weight, Cpu_session &cpu)
: Thread(weight.value, name.string(), stack_size, NORMAL,
&cpu, location)
{ }
Thread::Thread(Env &env, Name const &name, size_t stack_size)
: Thread(env, name, stack_size, Location(), Weight(), env.cpu()) { }
void Thread::cancel_blocking()
{
/*
* XXX implement interaction with CPU session
@ -491,7 +504,7 @@ void Thread_base::cancel_blocking()
}
Thread_base::~Thread_base()
Thread::~Thread()
{
bool const needs_join = (pthread_cancel(native_thread().meta_data->pt) == 0);

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) {

View File

@ -29,9 +29,9 @@ namespace Genode {
: Rpc_client<Nova_cpu_session>(static_cap_cast<Nova_cpu_session>(session)) { }
Thread_capability
create_thread(Capability<Pd_session> pd, size_t quota, Name const &name,
Affinity::Location affinity, addr_t utcb = 0) override {
return call<Rpc_create_thread>(pd, quota, name, affinity, utcb); }
create_thread(Capability<Pd_session> pd, Name const &name,
Affinity::Location affinity, Weight weight, addr_t utcb = 0) override {
return call<Rpc_create_thread>(pd, name, affinity, weight, utcb); }
Ram_dataspace_capability utcb(Thread_capability thread) override {
return call<Rpc_utcb>(thread); }

View File

@ -33,7 +33,7 @@ inline void request_event_portal(Genode::Native_capability const &cap,
Genode::addr_t sel, Genode::addr_t event,
unsigned short log2_count = 0)
{
Genode::Thread_base * myself = Genode::Thread_base::myself();
Genode::Thread * myself = Genode::Thread::myself();
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(myself->utcb());
/* save original receive window */
@ -73,7 +73,7 @@ inline void request_signal_sm_cap(Genode::Native_capability const &cap,
inline void delegate_vcpu_portals(Genode::Native_capability const &cap,
Genode::addr_t const sel)
{
Genode::Thread_base * myself = Genode::Thread_base::myself();
Genode::Thread * myself = Genode::Thread::myself();
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(myself->utcb());
/* save original receive window */

View File

@ -52,7 +52,7 @@ namespace Genode {
: Rpc_client<Nova_signal_source>(static_cap_cast<Nova_signal_source>(cap))
{
/* request mapping of semaphore capability selector */
Thread_base * myself = Thread_base::myself();
Thread * myself = Thread::myself();
request_signal_sm_cap(Native_capability(myself->native_thread().ec_sel + 1),
myself->native_thread().exc_pt_sel + Nova::PT_SEL_STARTUP);
_sem = Native_capability(myself->native_thread().exc_pt_sel + Nova::PT_SEL_STARTUP);

View File

@ -75,7 +75,7 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size,
throw Out_of_metadata();
/* map it */
Nova::Utcb * const utcb = reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb());
Nova::Utcb * const utcb = reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb());
const Nova::Rights rights(true, ds->writable(), executable);
if (map_local(utcb, ds->phys_addr(), reinterpret_cast<addr_t>(virt_ptr),
@ -94,7 +94,7 @@ void Core_region_map::detach(Local_addr core_local_addr)
{
size_t size = platform_specific()->region_alloc_size_at(core_local_addr);
unmap_local(reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb()),
unmap_local(reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb()),
core_local_addr, size >> get_page_size_log2());
platform()->region_alloc()->free(core_local_addr);

View File

@ -63,7 +63,7 @@ namespace Genode {
Pager_entrypoint &_pager_ep;
Capability<Pd_session> _pd;
Region_map_component &_address_space_region_map;
size_t const _weight;
Cpu_session::Weight const _weight;
Session_label const _session_label;
Thread_name const _name;
Platform_thread _platform_thread;
@ -119,7 +119,8 @@ namespace Genode {
* \param pager_ep pager entrypoint used for handling the page
* faults of the thread
* \param pd PD session where the thread is executed
* \param weight weighting regarding the CPU session quota
* \param weight scheduling weight relative to the other
* threads of the same CPU session
* \param quota initial quota counter-value of the weight
* \param labal label of the threads session
* \param name name for the thread
@ -127,24 +128,25 @@ namespace Genode {
* \param utcb user-local UTCB base
* \param sigh initial exception handler
*/
Cpu_thread_component(Cpu_session_capability cpu_session_cap,
Rpc_entrypoint &ep,
Pager_entrypoint &pager_ep,
Pd_session_component &pd,
Trace::Control_area &trace_control_area,
size_t const weight,
size_t const quota,
Affinity::Location affinity,
Session_label const &label,
Thread_name const &name,
unsigned priority, addr_t utcb,
Cpu_thread_component(Cpu_session_capability cpu_session_cap,
Rpc_entrypoint &ep,
Pager_entrypoint &pager_ep,
Pd_session_component &pd,
Trace::Control_area &trace_control_area,
Cpu_session::Weight weight,
size_t quota,
Affinity::Location location,
Session_label const &label,
Thread_name const &name,
unsigned priority,
addr_t utcb,
Signal_context_capability sigh)
:
_ep(ep), _pager_ep(pager_ep), _pd(pd.cap()),
_address_space_region_map(pd.address_space_region_map()),
_weight(weight),
_session_label(label), _name(name),
_platform_thread(name.string(), priority, affinity, utcb),
_platform_thread(name.string(), priority, location, utcb),
_bound_to_pd(_bind_to_pd(pd)),
_sigh(sigh),
_trace_control_slot(trace_control_area),
@ -193,9 +195,10 @@ namespace Genode {
************************/
Platform_thread *platform_thread() { return &_platform_thread; }
Trace::Source *trace_source() { return &_trace_source; }
size_t weight() const { return Cpu_session::DEFAULT_WEIGHT; }
Trace::Source *trace_source() { return &_trace_source; }
size_t weight() const { return Cpu_session::Weight::DEFAULT_WEIGHT; }
void sigh(Signal_context_capability sigh)
{
@ -317,8 +320,8 @@ namespace Genode {
** CPU session interface **
***************************/
Thread_capability create_thread(Capability<Pd_session>, size_t, Name const &,
Affinity::Location, addr_t) override;
Thread_capability create_thread(Capability<Pd_session>, Name const &,
Affinity::Location, Weight, addr_t) override;
Ram_dataspace_capability utcb(Thread_capability thread) override;
void kill_thread(Thread_capability) override;
int start(Thread_capability, addr_t, addr_t) override;

View File

@ -38,7 +38,7 @@ namespace Genode {
inline bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages,
bool read = true, bool write = true, bool exec = true)
{
return (::map_local((Nova::Utcb *)Thread_base::myself()->utcb(),
return (::map_local((Nova::Utcb *)Thread::myself()->utcb(),
from_phys, to_virt, num_pages,
Nova::Rights(read, write, exec), true) == 0);
}
@ -51,7 +51,7 @@ namespace Genode {
*/
inline void unmap_local(addr_t virt, size_t num_pages)
{
::unmap_local((Nova::Utcb *)Thread_base::myself()->utcb(),
::unmap_local((Nova::Utcb *)Thread::myself()->utcb(),
virt, num_pages);
}
}

View File

@ -364,7 +364,7 @@ namespace Genode {
* A 'Pager_activation' processes one page fault of a 'Pager_object' at a time.
*/
class Pager_entrypoint;
class Pager_activation_base: public Thread_base
class Pager_activation_base: public Thread
{
private:

View File

@ -30,7 +30,7 @@ void Ipc_pager::wait_for_fault()
* fault already occurred. So we never wait but immediately read the
* page-fault information from our UTCB.
*/
Nova::Utcb *utcb = (Nova::Utcb *)Thread_base::myself()->utcb();
Nova::Utcb *utcb = (Nova::Utcb *)Thread::myself()->utcb();
_fault_type = utcb->qual[0];
_fault_addr = utcb->qual[1];
_fault_ip = utcb->ip;
@ -39,7 +39,7 @@ void Ipc_pager::wait_for_fault()
void Ipc_pager::set_reply_mapping(Mapping m)
{
Nova::Utcb *utcb = (Nova::Utcb *)Thread_base::myself()->utcb();
Nova::Utcb *utcb = (Nova::Utcb *)Thread::myself()->utcb();
utcb->set_msg_word(0);
bool res = utcb->append_item(m.mem_crd(), m.dst_addr(), true, false,
false, m.dma(), m.write_combined());
@ -50,5 +50,5 @@ void Ipc_pager::set_reply_mapping(Mapping m)
void Ipc_pager::reply_and_wait_for_fault(unsigned sm)
{
Nova::reply(Thread_base::myself()->stack_top(), sm);
Nova::reply(Thread::myself()->stack_top(), sm);
}

View File

@ -82,7 +82,7 @@ static bool msi(Genode::addr_t irq_sel, Genode::addr_t phys_mem,
Nova::Mem_crd phys_crd(phys_mem >> 12, 0, Rights(true, false, false));
Nova::Mem_crd virt_crd(virt_addr >> 12, 0, Rights(true, false, false));
Utcb * utcb = reinterpret_cast<Utcb *>(Thread_base::myself()->utcb());
Utcb * utcb = reinterpret_cast<Utcb *>(Thread::myself()->utcb());
if (map_local_phys_to_virt(utcb, phys_crd, virt_crd)) {
platform()->region_alloc()->free(virt, 4096);
@ -142,7 +142,7 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys)
Obj_crd dst(irq_sel(), 0);
enum { MAP_FROM_KERNEL_TO_CORE = true };
int ret = map_local((Nova::Utcb *)Thread_base::myself()->utcb(),
int ret = map_local((Nova::Utcb *)Thread::myself()->utcb(),
src, dst, MAP_FROM_KERNEL_TO_CORE);
if (ret) {
PERR("Getting IRQ from kernel failed - %u", irq);

View File

@ -74,7 +74,7 @@ void Pager_object::_page_fault_handler(addr_t pager_obj)
Ipc_pager ipc_pager;
ipc_pager.wait_for_fault();
Thread_base * myself = Thread_base::myself();
Thread * myself = Thread::myself();
Pager_object * obj = reinterpret_cast<Pager_object *>(pager_obj);
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
Pager_activation_base * pager_thread = static_cast<Pager_activation_base *>(myself);
@ -130,7 +130,7 @@ void Pager_object::_page_fault_handler(addr_t pager_obj)
void Pager_object::exception(uint8_t exit_id)
{
Thread_base *myself = Thread_base::myself();
Thread *myself = Thread::myself();
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
Pager_activation_base * pager_thread = static_cast<Pager_activation_base *>(myself);
@ -187,7 +187,7 @@ void Pager_object::exception(uint8_t exit_id)
void Pager_object::_recall_handler(addr_t pager_obj)
{
Thread_base * myself = Thread_base::myself();
Thread * myself = Thread::myself();
Pager_object * obj = reinterpret_cast<Pager_object *>(pager_obj);
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
@ -234,7 +234,7 @@ void Pager_object::_recall_handler(addr_t pager_obj)
void Pager_object::_startup_handler(addr_t pager_obj)
{
Thread_base *myself = Thread_base::myself();
Thread *myself = Thread::myself();
Pager_object * obj = reinterpret_cast<Pager_object *>(pager_obj);
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
@ -250,7 +250,7 @@ void Pager_object::_startup_handler(addr_t pager_obj)
void Pager_object::_invoke_handler(addr_t pager_obj)
{
Thread_base *myself = Thread_base::myself();
Thread *myself = Thread::myself();
Pager_object * obj = reinterpret_cast<Pager_object *>(pager_obj);
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
@ -406,7 +406,7 @@ void Pager_object::cleanup_call()
/* revoke all portals handling the client. */
revoke(Obj_crd(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2));
Utcb *utcb = reinterpret_cast<Utcb *>(Thread_base::myself()->utcb());
Utcb *utcb = reinterpret_cast<Utcb *>(Thread::myself()->utcb());
utcb->set_msg_word(0);
utcb->mtd = 0;
if (uint8_t res = call(sel_pt_cleanup()))
@ -694,7 +694,7 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
asm volatile ("" : "=S" (reason));
}
Thread_base * myself = Thread_base::myself();
Thread * myself = Thread::myself();
Utcb * utcb = reinterpret_cast<Utcb *>(myself->utcb());
Pager_object * obj_dst = reinterpret_cast<Pager_object *>(pager_dst);
Pager_object * obj_src = reinterpret_cast<Pager_object *>(pager_src);
@ -822,14 +822,14 @@ addr_t Pager_object::get_oom_portal()
Pager_activation_base::Pager_activation_base(const char *name, size_t stack_size)
:
Thread_base(Cpu_session::DEFAULT_WEIGHT, name, stack_size,
Affinity::Location(which_cpu(this), 0)),
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size,
Affinity::Location(which_cpu(this), 0)),
_cap(Native_capability()), _ep(0), _cap_valid(Lock::LOCKED)
{
/* creates local EC */
Thread_base::start();
Thread::start();
reinterpret_cast<Nova::Utcb *>(Thread_base::utcb())->crd_xlt = Obj_crd(0, ~0UL);
reinterpret_cast<Nova::Utcb *>(Thread::utcb())->crd_xlt = Obj_crd(0, ~0UL);
}

View File

@ -282,7 +282,7 @@ Platform::Platform() :
* the y component of the affinity location. When adding support
* for two-dimensional affinity spaces, look out and adjust the use of
* 'Platform_thread::_location' in 'platform_thread.cc'. Also look
* at the 'Thread_base::start' function in core/thread_start.cc.
* at the 'Thread::start' function in core/thread_start.cc.
*/
_cpus = Affinity::Space(hip->cpus(), 1);
@ -765,7 +765,7 @@ Platform::Platform() :
bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
unsigned size)
{
map_local((Utcb *)Thread_base::myself()->utcb(), phys_addr,
map_local((Utcb *)Thread::myself()->utcb(), phys_addr,
virt_addr, size / get_page_size(),
Rights(true, true, true), true);
return true;
@ -774,7 +774,7 @@ bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, unsigned size)
{
unmap_local((Utcb *)Thread_base::myself()->utcb(),
unmap_local((Utcb *)Thread::myself()->utcb(),
virt_addr, size / get_page_size());
return true;
}

View File

@ -62,7 +62,7 @@ int Platform_thread::start(void *ip, void *sp)
}
addr_t const pt_oom = _pager->get_oom_portal();
if (!pt_oom || map_local((Utcb *)Thread_base::myself()->utcb(),
if (!pt_oom || map_local((Utcb *)Thread::myself()->utcb(),
Obj_crd(pt_oom, 0), Obj_crd(_sel_pt_oom(), 0))) {
PERR("setup of out-of-memory notification portal - failed");
return -8;
@ -124,7 +124,7 @@ int Platform_thread::start(void *ip, void *sp)
/* remap exception portals for first thread */
for (unsigned i = 0; i < sizeof(remap_dst)/sizeof(remap_dst[0]); i++) {
if (map_local((Utcb *)Thread_base::myself()->utcb(),
if (map_local((Utcb *)Thread::myself()->utcb(),
Obj_crd(remap_src[i], 0),
Obj_crd(_sel_exc_base + remap_dst[i], 0)))
return -6;

View File

@ -64,7 +64,7 @@ void Ram_session_component::_clear_ds(Dataspace_component *ds)
memset(reinterpret_cast<void *>(memset_ptr), 0, page_rounded_size);
/* we don't keep any core-local mapping */
unmap_local(reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb()),
unmap_local(reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb()),
ds->core_local_addr(),
page_rounded_size >> get_page_size_log2());
@ -85,7 +85,7 @@ void Ram_session_component::_export_ram_ds(Dataspace_component *ds) {
throw Out_of_metadata();
/* map it writeable for _clear_ds */
Nova::Utcb * const utcb = reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb());
Nova::Utcb * const utcb = reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb());
const Nova::Rights rights_rw(true, true, false);
if (map_local(utcb, ds->phys_addr(), reinterpret_cast<addr_t>(virt_ptr),

View File

@ -30,7 +30,7 @@
using namespace Genode;
void Thread_base::_init_platform_thread(size_t, Type type)
void Thread::_init_platform_thread(size_t, Type type)
{
/*
* This function is called for constructing server activations and pager
@ -46,7 +46,7 @@ void Thread_base::_init_platform_thread(size_t, Type type)
/*
* Exception base of first thread in core is 0. We have to set
* it here so that Thread_base code finds the semaphore of the
* it here so that Thread code finds the semaphore of the
* main thread.
*/
native_thread().exc_pt_sel = 0;
@ -67,7 +67,7 @@ void Thread_base::_init_platform_thread(size_t, Type type)
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
unmap_local(Nova::Obj_crd(native_thread().ec_sel, 1));
unmap_local(Nova::Obj_crd(native_thread().exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2));
@ -82,7 +82,7 @@ void Thread_base::_deinit_platform_thread()
}
void Thread_base::start()
void Thread::start()
{
/*
* On NOVA, core almost never starts regular threads. This simply creates a
@ -113,7 +113,7 @@ void Thread_base::start()
utcb_obj->crd_rcv = Obj_crd();
utcb_obj->crd_xlt = Obj_crd();
if (map_local(reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb()),
if (map_local(reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb()),
Obj_crd(PT_SEL_PAGE_FAULT, 0),
Obj_crd(native_thread().exc_pt_sel + PT_SEL_PAGE_FAULT, 0))) {
PERR("could not create page fault portal");
@ -122,7 +122,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
using namespace Nova;

View File

@ -34,7 +34,7 @@
extern int main_thread_running_semaphore();
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
{
Genode::addr_t sem = thread_base ?
thread_base->native_thread().exc_pt_sel + Nova::SM_SEL_EC :
@ -45,7 +45,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
}
static inline void thread_switch_to(Genode::Thread_base *thread_base) { }
static inline void thread_switch_to(Genode::Thread *thread_base) { }
static inline void thread_stop_myself()
@ -54,7 +54,7 @@ static inline void thread_stop_myself()
using namespace Nova;
addr_t sem;
Thread_base *myself = Thread_base::myself();
Thread *myself = Thread::myself();
if (myself)
sem = myself->native_thread().exc_pt_sel + SM_SEL_EC;
else

View File

@ -34,7 +34,7 @@ static inline void spinlock_lock(volatile T *lock_variable)
{
using Genode::cmpxchg;
Genode::Thread_base * myself = Genode::Thread_base::myself();
Genode::Thread * myself = Genode::Thread::myself();
T const tid = myself ? myself->native_thread().ec_sel : Nova::PT_SEL_MAIN_EC;
unsigned help_counter = 0;
@ -77,7 +77,7 @@ static inline void spinlock_unlock(volatile T *lock_variable)
{
using Nova::Utcb;
Genode::Thread_base * myself = Genode::Thread_base::myself();
Genode::Thread * myself = Genode::Thread::myself();
Utcb * utcb = myself ? reinterpret_cast<Utcb *>(myself->utcb()) : 0;
/* unlock */

View File

@ -43,7 +43,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
rcv_window.rcv_wnd(log2_max);
}
Nova::Utcb &utcb = *(Nova::Utcb *)Thread_base::myself()->utcb();
Nova::Utcb &utcb = *(Nova::Utcb *)Thread::myself()->utcb();
/* the protocol value is unused as the badge is delivered by the kernel */
if (!copy_msgbuf_to_utcb(utcb, snd_msg, 0)) {

View File

@ -83,7 +83,7 @@ void Rpc_entrypoint::_dissolve(Rpc_object_base *obj)
*/
using namespace Nova;
Utcb *utcb = reinterpret_cast<Utcb *>(Thread_base::myself()->utcb());
Utcb *utcb = reinterpret_cast<Utcb *>(Thread::myself()->utcb());
/* don't call ourself */
if (utcb == reinterpret_cast<Utcb *>(this->utcb()))
return;
@ -111,7 +111,7 @@ static void reply(Nova::Utcb &utcb, Rpc_exception_code exc, Msgbuf_base &snd_msg
{
copy_msgbuf_to_utcb(utcb, snd_msg, exc.value);
Nova::reply(Thread_base::myself()->stack_top());
Nova::reply(Thread::myself()->stack_top());
}
@ -124,8 +124,8 @@ void Rpc_entrypoint::_activation_entry()
addr_t id_pt; asm volatile ("" : "=a" (id_pt));
#endif
Rpc_entrypoint &ep = *static_cast<Rpc_entrypoint *>(Thread_base::myself());
Nova::Utcb &utcb = *(Nova::Utcb *)Thread_base::myself()->utcb();
Rpc_entrypoint &ep = *static_cast<Rpc_entrypoint *>(Thread::myself());
Nova::Utcb &utcb = *(Nova::Utcb *)Thread::myself()->utcb();
Receive_window &rcv_window = ep.native_thread().rcv_window;
rcv_window.post_ipc(utcb);
@ -219,7 +219,7 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
const char *name, bool start_on_construction,
Affinity::Location location)
:
Thread_base(Cpu_session::DEFAULT_WEIGHT, name, stack_size, location),
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size, location),
_delay_start(Lock::LOCKED),
_pd_session(*pd_session)
{
@ -228,7 +228,7 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
native_thread().ec_sel = Native_thread::INVALID_INDEX - 1;
/* required to create a 'local' EC */
Thread_base::start();
Thread::start();
/* create cleanup portal */
_cap = _alloc_rpc_cap(_pd_session, Native_capability(native_thread().ec_sel),
@ -236,7 +236,7 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
if (!_cap.valid())
throw Cpu_session::Thread_creation_failed();
Receive_window &rcv_window = Thread_base::native_thread().rcv_window;
Receive_window &rcv_window = Thread::native_thread().rcv_window;
/* prepare portal receive window of new thread */
if (!rcv_window.prepare_rcv_window(*(Nova::Utcb *)&_stack->utcb()))

View File

@ -27,7 +27,7 @@ void Genode::sleep_forever()
{
using namespace Nova;
Thread_base *myself = Thread_base::myself();
Thread *myself = Thread::myself();
addr_t sem = myself ? myself->native_thread().exc_pt_sel + SM_SEL_EC : SM_SEL_EC;
while (1) {

View File

@ -109,11 +109,11 @@ void prepare_reinit_main_thread()
}
/*****************
** Thread_base **
*****************/
/************
** Thread **
************/
Native_utcb *Thread_base::utcb()
Native_utcb *Thread::utcb()
{
/*
* If 'utcb' is called on the object returned by 'myself',

View File

@ -36,19 +36,17 @@ using namespace Genode;
/**
* Entry point entered by new threads
*/
void Thread_base::_thread_start()
void Thread::_thread_start()
{
using namespace Genode;
/* catch any exception at this point and try to print an error message */
try {
Thread_base::myself()->entry();
Thread::myself()->entry();
} catch (...) {
char thread_name[48];
Thread_base::myself()->name(thread_name, sizeof(thread_name));
try {
PERR("Thread '%s' died because of an uncaught exception", thread_name);
PERR("Thread '%s' died because of an uncaught exception",
Thread::myself()->name().string());
} catch (...) {
/* die in a noisy way */
nova_die();
@ -57,7 +55,7 @@ void Thread_base::_thread_start()
throw;
}
Thread_base::myself()->_join_lock.unlock();
Thread::myself()->_join_lock.unlock();
/* sleep silently */
Genode::sleep_forever();
@ -68,7 +66,7 @@ void Thread_base::_thread_start()
** Thread base **
*****************/
void Thread_base::_init_platform_thread(size_t weight, Type type)
void Thread::_init_platform_thread(size_t weight, Type type)
{
using namespace Nova;
@ -113,16 +111,14 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
_cpu_session = env()->cpu_session();
/* create thread at core */
char buf[48];
name(buf, sizeof(buf));
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), weight, buf, _affinity);
_thread_cap = _cpu_session->create_thread(env()->pd_session_cap(), name(),
_affinity, Weight(weight));
if (!_thread_cap.valid())
throw Cpu_session::Thread_creation_failed();
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
using namespace Nova;
@ -139,7 +135,7 @@ void Thread_base::_deinit_platform_thread()
}
void Thread_base::start()
void Thread::start()
{
if (native_thread().ec_sel < Native_thread::INVALID_INDEX - 1)
throw Cpu_session::Thread_creation_failed();
@ -201,7 +197,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
using namespace Nova;

View File

@ -76,7 +76,7 @@ void test_pat()
*/
Nova::Mem_crd snd_crd(map_addr >> PAGE_4K, DS_ORDER, all);
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb());
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb());
enum {
HOTSPOT = 0, USER_PD = false, HOST_PGT = false, SOLELY_MAP = false,
NO_DMA = false, EVILLY_DONT_WRITE_COMBINE = false
@ -186,13 +186,13 @@ void test_server_oom()
ep.dissolve(&component);
}
class Greedy : public Thread<4096> {
class Greedy : public Thread_deprecated<4096> {
public:
Greedy()
:
Thread<0x1000>("greedy")
Thread_deprecated<0x1000>("greedy")
{ }
void entry()
@ -272,7 +272,7 @@ int main(int argc, char **argv)
Genode::config()->xml_node().attribute("check_pat").value(&check_pat);
} catch (...) { }
Thread_base * myself = Thread_base::myself();
Thread * myself = Thread::myself();
if (!myself)
return -__LINE__;

View File

@ -92,4 +92,4 @@ Genode::Native_capability Test::Component::void_cap() {
}
Genode::addr_t Test::Component::leak_utcb_address() {
return reinterpret_cast<Genode::addr_t>(Genode::Thread_base::myself()->utcb()); }
return reinterpret_cast<Genode::addr_t>(Genode::Thread::myself()->utcb()); }

View File

@ -87,7 +87,7 @@ void Irq_object::_wait_for_irq()
void Irq_object::start()
{
::Thread_base::start();
::Thread::start();
_sync_bootup.lock();
}
@ -122,7 +122,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

@ -25,16 +25,16 @@
using namespace Genode;
void Thread_base::_thread_start()
void Thread::_thread_start()
{
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();
}
void Thread_base::start()
void Thread::start()
{
/* create and start platform thread */
native_thread().pt = new(platform_specific()->thread_slab())
@ -46,7 +46,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
/*
* Within core, we never need to unblock threads
@ -54,7 +54,7 @@ void Thread_base::cancel_blocking()
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform_specific()->thread_slab(), native_thread().pt);

View File

@ -46,7 +46,7 @@ extern Okl4::L4_ThreadId_t main_thread_tid;
*
* \return true if the thread was in blocking state
*/
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
{
using namespace Okl4;
@ -69,7 +69,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
/**
* Yield CPU time to the specified thread
*/
static inline void thread_switch_to(Genode::Thread_base *thread_base)
static inline void thread_switch_to(Genode::Thread *thread_base)
{
Okl4::L4_ThreadId_t tid = thread_base ?
thread_base->native_thread().l4id :
@ -83,7 +83,7 @@ static inline void thread_switch_to(Genode::Thread_base *thread_base)
*/
static inline void thread_stop_myself()
{
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Thread *myself = Genode::Thread::myself();
Okl4::L4_ThreadId_t tid = myself ?
myself->native_thread().l4id :
main_thread_tid;

View File

@ -69,17 +69,17 @@ 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()
{
native_thread().l4id.raw = Okl4::copy_uregister_to_utcb();
}
void Genode::Thread_base::_init_platform_thread(size_t, Type type)
void Genode::Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) { return; }
native_thread().l4id.raw = main_thread_tid.raw;

View File

@ -60,7 +60,7 @@ void Irq_object::_wait_for_irq()
void Irq_object::start()
{
::Thread_base::start();
::Thread::start();
_sync_bootup.lock();
}
@ -115,7 +115,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

@ -25,16 +25,16 @@
using namespace Genode;
void Thread_base::_thread_start()
void Thread::_thread_start()
{
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();
}
void Thread_base::start()
void Thread::start()
{
/* create and start platform thread */
native_thread().pt = new(platform()->core_mem_alloc())
@ -49,7 +49,7 @@ void Thread_base::start()
}
void Thread_base::cancel_blocking()
void Thread::cancel_blocking()
{
/*
* Within core, we never need to unblock threads
@ -57,7 +57,7 @@ void Thread_base::cancel_blocking()
}
void Thread_base::_deinit_platform_thread()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), native_thread().pt);

View File

@ -46,7 +46,7 @@ static inline void thread_yield() { Pistachio::L4_Yield(); }
*
* \return true if the thread was in blocking state
*/
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
{
using namespace Pistachio;
@ -70,7 +70,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
/**
* Yield CPU time to the specified thread
*/
static inline void thread_switch_to(Genode::Thread_base *thread_base)
static inline void thread_switch_to(Genode::Thread *thread_base)
{
Pistachio::L4_ThreadId_t tid = thread_base ?
thread_base->native_thread().l4id :
@ -84,7 +84,7 @@ static inline void thread_switch_to(Genode::Thread_base *thread_base)
*/
static inline void thread_stop_myself()
{
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Thread *myself = Genode::Thread::myself();
Pistachio::L4_ThreadId_t tid = myself ?
myself->native_thread().l4id :
main_thread_tid;

View File

@ -38,17 +38,17 @@ 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()
{
native_thread().l4id = Pistachio::L4_Myself();
}
void Genode::Thread_base::_init_platform_thread(size_t, Type type)
void Genode::Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) { return; }
native_thread().l4id = main_thread_tid;

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");
}

View File

@ -19,7 +19,7 @@
namespace Genode {
class Thread_base;
class Thread;
class Cancelable_lock;
}
@ -32,12 +32,12 @@ class Genode::Cancelable_lock
{
private:
Thread_base *_thread_base;
Applicant *_to_wake_up;
Thread *_thread_base;
Applicant *_to_wake_up;
public:
explicit Applicant(Thread_base *thread_base)
explicit Applicant(Thread *thread_base)
: _thread_base(thread_base), _to_wake_up(0) { }
void applicant_to_wake_up(Applicant *to_wake_up) {
@ -45,7 +45,7 @@ class Genode::Cancelable_lock
Applicant *applicant_to_wake_up() { return _to_wake_up; }
Thread_base *thread_base() { return _thread_base; }
Thread *thread_base() { return _thread_base; }
/**
* Called from previous lock owner

View File

@ -53,14 +53,13 @@ class Genode::Entrypoint : Genode::Noncopyable
}
};
enum { STACK_SIZE = 1024*sizeof(long) };
struct Signal_proxy_thread : Thread<STACK_SIZE>
struct Signal_proxy_thread : Thread
{
enum { STACK_SIZE = 1024*sizeof(long) };
Entrypoint &ep;
Signal_proxy_thread(Entrypoint &ep)
Signal_proxy_thread(Env &env, Entrypoint &ep)
:
Thread<STACK_SIZE>("signal_proxy"),
Thread(env, "signal_proxy", STACK_SIZE),
ep(ep)
{ }

View File

@ -249,7 +249,7 @@ struct Genode::Rpc_object : Rpc_object_base, Rpc_dispatcher<RPC_INTERFACE, SERVE
* shortcut for the common case where the server's capability is handed
* over to other parties _after_ the server is completely initialized.
*/
class Genode::Rpc_entrypoint : Thread_base, public Object_pool<Rpc_object_base>
class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
{
private:

View File

@ -26,19 +26,20 @@
namespace Genode {
struct Native_utcb;
struct Native_thread;
class Thread_base;
class Thread;
class Stack;
template <unsigned> class Thread;
class Env;
template <unsigned> class Thread_deprecated;
}
/**
* Concurrent flow of control
*
* A 'Thread_base' object corresponds to a physical thread. The execution
* A 'Thread' object corresponds to a physical thread. The execution
* starts at the 'entry()' method as soon as 'start()' is called.
*/
class Genode::Thread_base
class Genode::Thread
{
public:
@ -46,6 +47,10 @@ class Genode::Thread_base
class Stack_too_large : public Exception { };
class Stack_alloc_failed : public Exception { };
typedef Affinity::Location Location;
typedef Cpu_session::Name Name;
typedef Cpu_session::Weight Weight;
private:
/**
@ -157,13 +162,17 @@ class Genode::Thread_base
* gets skipped but we should at least set Stack::ds_cap in a
* way that it references the dataspace of the already attached
* stack.
*
* \deprecated superseded by the 'Thread(Env &...' constructor
*/
Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Affinity::Location affinity = Affinity::Location());
Thread(size_t weight, const char *name, size_t stack_size,
Type type, Affinity::Location affinity = Affinity::Location());
/**
* Constructor
*
* \noapi
*
* \param weight weighting regarding the CPU session quota
* \param name thread name (for debugging)
* \param stack_size stack size
@ -176,10 +185,12 @@ class Genode::Thread_base
* of the component environment. A small portion of the stack size is
* internally used by the framework for storing thread-specific
* information such as the thread's name.
*
* \deprecated superseded by the 'Thread(Env &...' constructor
*/
Thread_base(size_t weight, const char *name, size_t stack_size,
Affinity::Location affinity = Affinity::Location())
: Thread_base(weight, name, stack_size, NORMAL, affinity) { }
Thread(size_t weight, const char *name, size_t stack_size,
Affinity::Location affinity = Affinity::Location())
: Thread(weight, name, stack_size, NORMAL, affinity) { }
/**
* Constructor
@ -199,15 +210,51 @@ class Genode::Thread_base
* \throw Stack_too_large
* \throw Stack_alloc_failed
* \throw Out_of_stack_space
*
* \deprecated superseded by the 'Thread(Env &...' constructor
*/
Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session *,
Affinity::Location affinity = Affinity::Location());
Thread(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session *,
Affinity::Location affinity = Affinity::Location());
/**
* Constructor
*
* \param env component environment
* \param name thread name, used for debugging
* \param stack_size stack size
* \param location CPU affinity relative to the CPU-session's
* affinity space
* \param weight scheduling weight relative to the other threads
* sharing the same CPU session
* \param cpu_session CPU session used to create the thread. Normally
* 'env.cpu()' should be specified.
*
* The 'env' argument is needed because the thread creation procedure
* needs to interact with the environment for attaching the thread's
* stack, the trace-control dataspace, and the thread's trace buffer
* and policy.
*
* \throw Stack_too_large
* \throw Stack_alloc_failed
* \throw Out_of_stack_space
*/
Thread(Env &env, Name const &name, size_t stack_size, Location location,
Weight weight, Cpu_session &cpu);
/**
* Constructor
*
* This is a shortcut for the common case of creating a thread via
* the environment's CPU session, at the default affinity location, and
* with the default weight.
*/
Thread(Env &env, Name const &name, size_t stack_size);
/**
* Destructor
*/
virtual ~Thread_base();
virtual ~Thread();
/**
* Entry method of the thread
@ -224,9 +271,17 @@ class Genode::Thread_base
/**
* Request name of thread
*
* \noapi
* \deprecated use the 'Name name() const' method instead
*/
void name(char *dst, size_t dst_len);
/**
* Request name of thread
*/
Name name() const;
/**
* Add an additional stack to the thread
*
@ -293,11 +348,11 @@ class Genode::Thread_base
static size_t stack_area_virtual_size();
/**
* Return 'Thread_base' object corresponding to the calling thread
* Return 'Thread' object corresponding to the calling thread
*
* \return pointer to caller's 'Thread_base' object
* \return pointer to caller's 'Thread' object
*/
static Thread_base *myself();
static Thread *myself();
/**
* Ensure that the stack has a given size at the minimum
@ -352,7 +407,7 @@ class Genode::Thread_base
template <unsigned STACK_SIZE>
class Genode::Thread : public Thread_base
class Genode::Thread_deprecated : public Thread
{
public:
@ -363,8 +418,8 @@ class Genode::Thread : public Thread_base
* \param name thread name (for debugging)
* \param type enables selection of special construction
*/
explicit Thread(size_t weight, const char *name)
: Thread_base(weight, name, STACK_SIZE, Type::NORMAL) { }
explicit Thread_deprecated(size_t weight, const char *name)
: Thread(weight, name, STACK_SIZE, Type::NORMAL) { }
/**
* Constructor
@ -375,8 +430,8 @@ class Genode::Thread : public Thread_base
*
* \noapi
*/
explicit Thread(size_t weight, const char *name, Type type)
: Thread_base(weight, name, STACK_SIZE, type) { }
explicit Thread_deprecated(size_t weight, const char *name, Type type)
: Thread(weight, name, STACK_SIZE, type) { }
/**
* Constructor
@ -387,25 +442,25 @@ class Genode::Thread : public Thread_base
*
* \noapi
*/
explicit Thread(size_t weight, const char *name,
explicit Thread_deprecated(size_t weight, const char *name,
Cpu_session * cpu_session)
: Thread_base(weight, name, STACK_SIZE, Type::NORMAL, cpu_session) { }
: Thread(weight, name, STACK_SIZE, Type::NORMAL, cpu_session) { }
/**
* Shortcut for 'Thread(DEFAULT_WEIGHT, name, type)'
*
* \noapi
*/
explicit Thread(const char *name, Type type = NORMAL)
: Thread_base(Cpu_session::DEFAULT_WEIGHT, name, STACK_SIZE, type) { }
explicit Thread_deprecated(const char *name, Type type = NORMAL)
: Thread(Weight::DEFAULT_WEIGHT, name, STACK_SIZE, type) { }
/**
* Shortcut for 'Thread(DEFAULT_WEIGHT, name, cpu_session)'
*
* \noapi
*/
explicit Thread(const char *name, Cpu_session * cpu_session)
: Thread_base(Cpu_session::DEFAULT_WEIGHT, name, STACK_SIZE,
explicit Thread_deprecated(const char *name, Cpu_session * cpu_session)
: Thread(Weight::DEFAULT_WEIGHT, name, STACK_SIZE,
Type::NORMAL, cpu_session)
{ }
};

View File

@ -36,7 +36,7 @@ struct Genode::Trace::Rpc_call
Rpc_call(char const *rpc_name, Msgbuf_base const &msg)
: rpc_name(rpc_name), msg(msg)
{
Thread_base::trace(this);
Thread::trace(this);
}
size_t generate(Policy_module &policy, char *dst) const {
@ -52,7 +52,7 @@ struct Genode::Trace::Rpc_returned
Rpc_returned(char const *rpc_name, Msgbuf_base const &msg)
: rpc_name(rpc_name), msg(msg)
{
Thread_base::trace(this);
Thread::trace(this);
}
size_t generate(Policy_module &policy, char *dst) const {
@ -68,7 +68,7 @@ struct Genode::Trace::Rpc_dispatch
:
rpc_name(rpc_name)
{
Thread_base::trace(this);
Thread::trace(this);
}
size_t generate(Policy_module &policy, char *dst) const {
@ -84,7 +84,7 @@ struct Genode::Trace::Rpc_reply
:
rpc_name(rpc_name)
{
Thread_base::trace(this);
Thread::trace(this);
}
size_t generate(Policy_module &policy, char *dst) const {
@ -97,7 +97,7 @@ struct Genode::Trace::Signal_submit
unsigned const num;
Signal_submit(unsigned const num) : num(num)
{ Thread_base::trace(this); }
{ Thread::trace(this); }
size_t generate(Policy_module &policy, char *dst) const {
return policy.signal_submit(dst, num); }
@ -113,7 +113,7 @@ struct Genode::Trace::Signal_received
:
signal_context(signal_context), num(num)
{
Thread_base::trace(this);
Thread::trace(this);
}
size_t generate(Policy_module &policy, char *dst) const {

View File

@ -26,9 +26,9 @@ struct Genode::Cpu_session_client : Rpc_client<Cpu_session>
: Rpc_client<Cpu_session>(session) { }
Thread_capability
create_thread(Capability<Pd_session> pd, size_t quota, Name const &name,
Affinity::Location affinity, addr_t utcb = 0) override {
return call<Rpc_create_thread>(pd, quota, name, affinity, utcb); }
create_thread(Capability<Pd_session> pd, Name const &name,
Affinity::Location affinity, Weight weight, addr_t utcb = 0) override {
return call<Rpc_create_thread>(pd, name, affinity, weight, utcb); }
Ram_dataspace_capability utcb(Thread_capability thread) override {
return call<Rpc_utcb>(thread); }

View File

@ -42,14 +42,24 @@ struct Genode::Cpu_session : Session
static const char *service_name() { return "CPU"; }
enum { THREAD_NAME_LEN = 48 };
enum { THREAD_NAME_LEN = 32 };
enum { PRIORITY_LIMIT = 1 << 16 };
enum { QUOTA_LIMIT_LOG2 = 15 };
enum { QUOTA_LIMIT = 1 << QUOTA_LIMIT_LOG2 };
enum { DEFAULT_PRIORITY = 0 };
enum { DEFAULT_WEIGHT = 10 };
typedef Rpc_in_buffer<THREAD_NAME_LEN> Name;
/**
* Thread weight argument type for 'create_thread'
*/
struct Weight
{
enum { DEFAULT_WEIGHT = 10 };
size_t value = DEFAULT_WEIGHT;
Weight() { }
explicit Weight(size_t value) : value(value) { }
};
typedef String<THREAD_NAME_LEN> Name;
/**
* Physical quota configuration
@ -62,20 +72,20 @@ struct Genode::Cpu_session : Session
* Create a new thread
*
* \param pd protection domain where the thread will be executed
* \param quota CPU quota that shall be granted to the thread
* \param name name for the thread
* \param affinity CPU affinity, referring to the session-local
* affinity space
* \param utcb Base of the UTCB that will be used by the thread
* \param weight CPU quota that shall be granted to the thread
* \param utcb base of the UTCB that will be used by the thread
* \return capability representing the new thread
* \throw Thread_creation_failed
* \throw Out_of_metadata
* \throw Quota_exceeded
*/
virtual Thread_capability create_thread(Capability<Pd_session> pd,
size_t quota,
Name const &name,
Affinity::Location affinity = Affinity::Location(),
Affinity::Location affinity,
Weight weight,
addr_t utcb = 0) = 0;
/**
@ -317,8 +327,8 @@ struct Genode::Cpu_session : Session
GENODE_RPC_THROW(Rpc_create_thread, Thread_capability, create_thread,
GENODE_TYPE_LIST(Thread_creation_failed, Out_of_metadata),
Capability<Pd_session>, size_t, Name const &,
Affinity::Location, addr_t);
Capability<Pd_session>, Name const &, Affinity::Location,
Weight, addr_t);
GENODE_RPC(Rpc_utcb, Ram_dataspace_capability, utcb, Thread_capability);
GENODE_RPC(Rpc_kill_thread, void, kill_thread, Thread_capability);
GENODE_RPC(Rpc_start, int, start, Thread_capability, addr_t, addr_t);

View File

@ -2,11 +2,21 @@ build "core init test/thread"
create_boot_directory
install_config {
#
# We skip pause-resume test on platforms where this functionality is not
# supported.
#
proc pause_resume_supported { } {
if {[have_spec pistachio]} { return 0 }
if {[have_spec linux]} { return 0 }
if {[have_spec fiasco]} { return 0 }
return 1;
}
set config {
<config>
<parent-provides>
<service name="LOG"/>
<service name="RM"/>
<service name="CPU"/>
</parent-provides>
<default-route>
@ -14,27 +24,21 @@ install_config {
</default-route>
<start name="test-thread">
<resource name="RAM" quantum="10M"/>
<config>}
append_if [pause_resume_supported] config { <pause_resume/> }
append config {
</config>
</start>
</config>
}
install_config $config
build_boot_image "core init test-thread"
append qemu_args "-nographic -m 64"
run_genode_until {child "test-thread" exited with exit value .*\n} 60
run_genode_until {.*test completed successfully.*\n} 60
# determine error code of child exit
set exit_code [regexp -inline {child "test-thread" exited with exit value .*\n} $output]
set exit_code [regexp -inline {[-+]?[0-9]+} $exit_code]
# good case
if {$exit_code eq 0} {
return
}
# no pause/resume support for Fiasco and Pistachio - they may return a error
if {[expr [have_spec fiasco] || [have_spec pistachio]] && $exit_code eq -11} { return }
# no puase/resume support for Linux - it may return a error
if {[have_spec linux] && $exit_code eq -10} { return }
exit -1

View File

@ -35,27 +35,27 @@ void Cpu_thread_component::update_exception_sigh()
Thread_capability Cpu_session_component::create_thread(Capability<Pd_session> pd_cap,
size_t weight,
Name const &name,
Affinity::Location affinity,
Weight weight,
addr_t utcb)
{
Trace::Thread_name thread_name(name.string());
Cpu_thread_component *thread = 0;
if (weight == 0) {
if (weight.value == 0) {
PWRN("Thread %s: Bad weight 0, using %i instead.",
name.string(), DEFAULT_WEIGHT);
weight = DEFAULT_WEIGHT;
name.string(), Weight::DEFAULT_WEIGHT);
weight = Weight();
}
if (weight > QUOTA_LIMIT) {
if (weight.value > QUOTA_LIMIT) {
PWRN("Thread %s: Oversized weight %zu, using %i instead.",
name.string(), weight, QUOTA_LIMIT);
weight = QUOTA_LIMIT;
name.string(), weight.value, QUOTA_LIMIT);
weight = Weight(QUOTA_LIMIT);
}
Lock::Guard thread_list_lock_guard(_thread_list_lock);
_incr_weight(weight);
_incr_weight(weight.value);
/*
* Create thread associated with its protection domain
@ -69,7 +69,7 @@ Thread_capability Cpu_session_component::create_thread(Capability<Pd_session> pd
thread = new (&_thread_alloc)
Cpu_thread_component(
cap(), *_thread_ep, *_pager_ep, *pd, _trace_control_area,
weight, _weight_to_quota(weight),
weight, _weight_to_quota(weight.value),
_thread_affinity(affinity), _label, thread_name,
_priority, utcb, _default_exception_handler);
};

View File

@ -60,7 +60,7 @@ namespace Genode {
Pager_entrypoint &_pager_ep;
Capability<Pd_session> _pd;
Region_map_component &_address_space_region_map;
size_t const _weight;
Cpu_session::Weight const _weight;
Session_label const _session_label;
Thread_name const _name;
Platform_thread _platform_thread;
@ -116,7 +116,8 @@ namespace Genode {
* \param pager_ep pager entrypoint used for handling the page
* faults of the thread
* \param pd PD session where the thread is executed
* \param weight weighting regarding the CPU session quota
* \param weight scheduling weight relative to the other
* threads of the same CPU session
* \param quota initial quota counter-value of the weight
* \param labal label of the threads session
* \param name name for the thread
@ -124,24 +125,25 @@ namespace Genode {
* \param utcb user-local UTCB base
* \param sigh initial exception handler
*/
Cpu_thread_component(Cpu_session_capability cpu_session_cap,
Rpc_entrypoint &ep,
Pager_entrypoint &pager_ep,
Pd_session_component &pd,
Trace::Control_area &trace_control_area,
size_t const weight,
size_t const quota,
Affinity::Location affinity,
Session_label const &label,
Thread_name const &name,
unsigned priority, addr_t utcb,
Cpu_thread_component(Cpu_session_capability cpu_session_cap,
Rpc_entrypoint &ep,
Pager_entrypoint &pager_ep,
Pd_session_component &pd,
Trace::Control_area &trace_control_area,
Cpu_session::Weight weight,
size_t quota,
Affinity::Location location,
Session_label const &label,
Thread_name const &name,
unsigned priority,
addr_t utcb,
Signal_context_capability sigh)
:
_ep(ep), _pager_ep(pager_ep), _pd(pd.cap()),
_address_space_region_map(pd.address_space_region_map()),
_weight(weight),
_session_label(label), _name(name),
_platform_thread(quota, name.string(), priority, affinity, utcb),
_platform_thread(quota, name.string(), priority, location, utcb),
_bound_to_pd(_bind_to_pd(pd)),
_sigh(sigh),
_trace_control_slot(trace_control_area),
@ -195,7 +197,7 @@ namespace Genode {
Trace::Source *trace_source() { return &_trace_source; }
size_t weight() const { return _weight; }
size_t weight() const { return _weight.value; }
void sigh(Signal_context_capability sigh)
{
@ -340,8 +342,8 @@ namespace Genode {
** CPU session interface **
***************************/
Thread_capability create_thread(Capability<Pd_session>, size_t, Name const &,
Affinity::Location, addr_t) override;
Thread_capability create_thread(Capability<Pd_session>, Name const &,
Affinity::Location, Weight, addr_t) override;
Ram_dataspace_capability utcb(Thread_capability thread) override;
void kill_thread(Thread_capability) override;
int start(Thread_capability, addr_t, addr_t) override;

View File

@ -18,7 +18,7 @@
namespace Genode { class Irq_object; }
class Genode::Irq_object : public Thread<4096> {
class Genode::Irq_object : public Thread_deprecated<4096> {
private:

View File

@ -141,7 +141,7 @@ class Genode::Pager_object : public Object_pool<Pager_object>::Entry
class Genode::Pager_entrypoint : public Object_pool<Pager_object>,
public Thread<PAGER_EP_STACK_SIZE>
public Thread_deprecated<PAGER_EP_STACK_SIZE>
{
private:
@ -161,7 +161,7 @@ class Genode::Pager_entrypoint : public Object_pool<Pager_object>,
*/
Pager_entrypoint(Rpc_cap_factory &cap_factory)
:
Thread<PAGER_EP_STACK_SIZE>("pager_ep"),
Thread_deprecated<PAGER_EP_STACK_SIZE>("pager_ep"),
_cap_factory(cap_factory)
{ start(); }

View File

@ -22,6 +22,9 @@
#include <rom_session/connection.h>
#include <cpu_session/connection.h>
/* base-internal includes */
#include <base/internal/globals.h>
/* core includes */
#include <platform.h>
#include <core_env.h>
@ -195,7 +198,7 @@ class Core_child : public Child_policy
* the creation of regular threads within core is unsupported.
*/
namespace Genode { void init_signal_thread() { } }
namespace Genode { void init_signal_thread(Env &) { } }
/*******************

View File

@ -40,13 +40,13 @@ struct Genode::Expanding_cpu_session_client : Upgradeable_client<Genode::Cpu_ses
{ }
Thread_capability
create_thread(Pd_session_capability pd, size_t quota, Name const &name,
Affinity::Location location, addr_t utcb)
create_thread(Pd_session_capability pd, Name const &name,
Affinity::Location location, Weight weight, addr_t utcb) override
{
return retry<Cpu_session::Out_of_metadata>(
[&] () {
return Cpu_session_client::create_thread(pd, quota, name,
location, utcb); },
return Cpu_session_client::create_thread(pd, name, location,
weight, utcb); },
[&] () { upgrade_ram(8*1024); });
}
};

View File

@ -21,11 +21,12 @@ namespace Genode {
class Region_map;
class Ram_session;
class Env;
extern Region_map *env_stack_area_region_map;
extern Ram_session *env_stack_area_ram_session;
void init_signal_thread();
void init_signal_thread(Env &);
void init_log();
}

View File

@ -30,14 +30,14 @@
* data shared between the user-level thread and the kernel. It is typically
* used for transferring IPC message payload or for system-call arguments.
* The additional stack members are a reference to the corresponding
* 'Thread_base' object and the name of the thread.
* 'Thread' object and the name of the thread.
*
* The stack area is a virtual memory area, initially not backed by real
* memory. When a new thread is created, an empty slot gets assigned to the new
* thread and populated with memory pages for the stack and thread-specific
* data. Note that this memory is allocated from the RAM session of the
* component environment and not accounted for when using the 'sizeof()'
* operand on a 'Thread_base' object.
* operand on a 'Thread' object.
*
* A thread may be associated with more than one stack. Additional secondary
* stacks can be associated with a thread, and used for user level scheduling.
@ -58,6 +58,7 @@
#include <base/native_types.h> /* for 'Native_utcb' */
#include <cpu/consts.h>
#include <ram_session/ram_session.h> /* for 'Ram_dataspace_capability' type */
#include <cpu_session/cpu_session.h> /* for 'Cpu_session::Name' type */
/* base-internal includes */
#include <base/internal/native_utcb.h>
@ -75,7 +76,7 @@ class Genode::Stack
{
public:
typedef String<64> Name;
typedef Cpu_session::Name Name;
private:
@ -93,9 +94,9 @@ class Genode::Stack
Name const _name;
/**
* Pointer to corresponding 'Thread_base' object
* Pointer to corresponding 'Thread' object
*/
Thread_base &_thread;
Thread &_thread;
/**
* Virtual address of the start of the stack
@ -135,7 +136,7 @@ class Genode::Stack
/**
* Constructor
*/
Stack(Name const &name, Thread_base &thread, addr_t base,
Stack(Name const &name, Thread &thread, addr_t base,
Ram_dataspace_capability ds_cap)
:
_name(name), _thread(thread), _base(base), _ds_cap(ds_cap)
@ -179,9 +180,9 @@ class Genode::Stack
Name name() const { return _name; }
/**
* Return 'Thread_base' object of the stack's thread
* Return 'Thread' object of the stack's thread
*/
Thread_base &thread() { return _thread; }
Thread &thread() { return _thread; }
/**
* Return dataspace used as the stack's backing storage

View File

@ -59,7 +59,7 @@ class Genode::Stack_allocator
* \return virtual address of new stack, or
* 0 if the allocation failed
*/
Stack *alloc(Thread_base *thread, bool main_thread);
Stack *alloc(Thread *thread, bool main_thread);
/**
* Release stack

View File

@ -167,7 +167,7 @@ Child::Process::Initial_thread::Initial_thread(Cpu_session &cpu,
char const *name)
:
cpu(cpu),
cap(cpu.create_thread(pd, Cpu_session::DEFAULT_WEIGHT, name))
cap(cpu.create_thread(pd, name, Affinity::Location(), Cpu_session::Weight()))
{ }

View File

@ -12,11 +12,14 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/entrypoint.h>
#include <base/component.h>
#include <cap_session/connection.h>
#include <util/retry.h>
/* base-internal includes */
#include <base/internal/globals.h>
using namespace Genode;
@ -27,7 +30,6 @@ namespace Genode {
extern bool inhibit_tracing;
void call_global_static_constructors();
void init_signal_thread();
void destroy_signal_thread();
extern void (*call_component_construct)(Genode::Env &);
@ -76,7 +78,7 @@ void Entrypoint::_process_incoming_signals()
/* execute fork magic in noux plugin */
_suspended_callback();
init_signal_thread();
init_signal_thread(_env);
_rpc_ep.construct(&_env.pd(), Component::stack_size(), Component::name());
_signal_proxy_cap = manage(_signal_proxy);
_sig_rec.construct();
@ -155,7 +157,7 @@ Entrypoint::Entrypoint(Env &env)
_rpc_ep(&env.pd(), Component::stack_size(), Component::name())
{
/* initialize signalling after initializing but before calling the entrypoint */
init_signal_thread();
init_signal_thread(_env);
/*
* Invoke Component::construct function in the context of the entrypoint.
@ -186,6 +188,6 @@ Entrypoint::Entrypoint(Env &env, size_t stack_size, char const *name)
_env(env),
_rpc_ep(&env.pd(), stack_size, name)
{
_signal_proxy_thread.construct(*this);
_signal_proxy_thread.construct(env, *this);
}

View File

@ -21,13 +21,13 @@
using namespace Genode;
static inline Genode::Thread_base *invalid_thread_base()
static inline Genode::Thread *invalid_thread_base()
{
return (Genode::Thread_base*)~0;
return (Genode::Thread*)~0;
}
static inline bool thread_base_valid(Genode::Thread_base *thread_base)
static inline bool thread_base_valid(Genode::Thread *thread_base)
{
return (thread_base != invalid_thread_base());
}
@ -62,7 +62,7 @@ void Cancelable_lock::Applicant::wake_up()
void Cancelable_lock::lock()
{
Applicant myself(Thread_base::myself());
Applicant myself(Thread::myself());
spinlock_lock(&_spinlock_state);

View File

@ -60,7 +60,7 @@ void Rpc_entrypoint::activate()
bool Rpc_entrypoint::is_myself() const
{
return (Thread_base::myself() == this);
return (Thread::myself() == this);
}
@ -68,13 +68,13 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
char const *name, bool start_on_construction,
Affinity::Location location)
:
Thread_base(Cpu_session::DEFAULT_WEIGHT, name, stack_size, location),
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size, location),
_cap(Untyped_capability()),
_cap_valid(Lock::LOCKED), _delay_start(Lock::LOCKED),
_delay_exit(Lock::LOCKED),
_pd_session(*pd_session)
{
Thread_base::start();
Thread::start();
_block_until_cap_valid();
if (start_on_construction)

View File

@ -11,6 +11,7 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <util/retry.h>
#include <base/env.h>
#include <base/signal.h>
@ -20,11 +21,12 @@
#include <signal_source/client.h>
#include <util/volatile_object.h>
/* base-internal includes */
#include <base/internal/globals.h>
using namespace Genode;
enum { STACK_SIZE = 4*1024*sizeof(addr_t) };
class Signal_handler_thread : Thread<STACK_SIZE>, Lock
class Signal_handler_thread : Thread, Lock
{
private:
@ -44,13 +46,15 @@ class Signal_handler_thread : Thread<STACK_SIZE>, Lock
Signal_receiver::dispatch_signals(&(*_signal_source));
}
enum { STACK_SIZE = 4*1024*sizeof(addr_t) };
public:
/**
* Constructor
*/
Signal_handler_thread()
: Thread<STACK_SIZE>("signal handler"), Lock(Lock::LOCKED)
Signal_handler_thread(Env &env)
: Thread(env, "signal handler", STACK_SIZE), Lock(Lock::LOCKED)
{
start();
@ -92,10 +96,10 @@ namespace Genode {
* We allow this function to be overridden in to enable core to omit the
* creation of the signal thread.
*/
void init_signal_thread() __attribute__((weak));
void init_signal_thread()
void init_signal_thread(Env &env) __attribute__((weak));
void init_signal_thread(Env &env)
{
signal_handler_thread().construct();
signal_handler_thread().construct(env);
}
void destroy_signal_thread()

Some files were not shown because too many files have changed in this diff Show More