diff --git a/repos/base-foc/src/core/include/platform_thread.h b/repos/base-foc/src/core/include/platform_thread.h index 5d45f2006..35f723143 100644 --- a/repos/base-foc/src/core/include/platform_thread.h +++ b/repos/base-foc/src/core/include/platform_thread.h @@ -206,6 +206,7 @@ namespace Genode { Name name() const { return _name; } bool core_thread() const { return _core_thread; } addr_t utcb() const { return _utcb; } + unsigned prio() const { return _prio; } }; } diff --git a/repos/base-foc/src/core/thread_start.cc b/repos/base-foc/src/core/thread_start.cc index 3cd60c7a3..802d0b992 100644 --- a/repos/base-foc/src/core/thread_start.cc +++ b/repos/base-foc/src/core/thread_start.cc @@ -15,6 +15,7 @@ /* Genode includes */ #include #include +#include /* base-internal includes */ #include @@ -26,6 +27,8 @@ namespace Fiasco { #include #include +#include +#include } using namespace Genode; @@ -65,6 +68,47 @@ void Thread::start() l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this; pt.start((void *)_thread_start, stack_top()); + + struct Core_trace_source : public Trace::Source::Info_accessor, + private Trace::Control, + private Trace::Source + { + Thread &thread; + Platform_thread &platform_thread; + + /** + * Trace::Source::Info_accessor interface + */ + Info trace_source_info() const override + { + uint64_t const sc_time = 0; + addr_t const kcap = (addr_t) platform_thread.pager_object_badge(); + + using namespace Fiasco; + l4_kernel_clock_t ec_time = 0; + l4_msgtag_t res = l4_thread_stats_time(kcap, &ec_time); + if (l4_error(res)) + Genode::error("cpu time for ", thread.name(), + " is not available ", l4_error(res)); + + return { Session_label("core"), thread.name(), + Trace::Execution_time(ec_time, sc_time, 10000, + platform_thread.prio()), + thread._affinity }; + } + + Core_trace_source(Trace::Source_registry ®istry, Thread &t, + Platform_thread &pt) + : + Trace::Control(), + Trace::Source(*this, *this), thread(t), platform_thread(pt) + { + registry.insert(this); + } + }; + + new (platform().core_mem_alloc()) Core_trace_source(Trace::sources(), + *this, pt); }