2 #include <l4/plr/measurements.h>
3 #include <pthread-l4.h>
4 #include <l4/util/rdtsc.h>
5 #include <l4/sys/debugger.h>
6 #include <l4/sys/kdebug.h>
7 #include <l4/sys/scheduler>
9 #include <l4/re/error_helper>
20 static timerArgs global_arg;
22 void *timerThread(void *argp)
24 char const *name = "Romain::timer";
25 L4::Cap<L4::Thread> self(pthread_getl4cap(pthread_self()));
26 l4_debugger_set_object_name(self.cap(), name);
28 l4_sched_param_t sp = l4_sched_param(2);
29 sp.affinity = l4_sched_cpu_set(global_arg.cpu, 0);
30 chksys(L4Re::Env::env()->scheduler()->run_thread(self, sp));
32 INFO() << "Timer thread. CPU " << global_arg.cpu << ". Timestamp @ 0x" << std::hex << global_arg.timer;
35 *((volatile l4_uint64_t*)global_arg.timer) = l4_rdtsc();
38 enter_kdebug("timer returned");
44 Measurements::EventBuf::launchTimerThread(l4_addr_t timer, unsigned CPU)
48 global_arg.timer = timer;
51 int err = pthread_create(&tmr, 0, timerThread, (void*)&global_arg);
53 ERROR() << "Error creating timer thread: " << err;