3 * \brief Functions to acquire thread time fast (without kernel entry)
5 * \date Martin Pohlack <mp26@os.inf.tu-dresden.de> */
8 * (c) 2005-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9 * Martin Pohlack <mp26@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU Lesser General Public License 2.1.
13 * Please see the COPYING-LGPL-2.1 file for details.
17 #ifndef __L4UTIL__INCLUDE__ARCH_X86__THREAD_TIME_H__
18 #define __L4UTIL__INCLUDE__ARCH_X86__THREAD_TIME_H__
20 #include <l4/sys/kip.h>
21 #include <l4/util/rdtsc.h>
26 * \brief Acquire accumulated runtime from the kernel info page for currently
29 * @param kinfo pointer to mapped kernel info page
31 * \return Accumulated thread time (cycles)
33 L4_INLINE l4_cpu_time_t l4util_thread_time(const l4_kernel_info_t * kinfo);
34 L4_INLINE l4_cpu_time_t l4util_thread_time(const l4_kernel_info_t * kinfo)
36 l4_cpu_time_t switch_time, thread_time, now;
41 /* fixme: make 64 bit reads atomic ??? */
42 thread_time = kinfo->thread_time;
43 switch_time = kinfo->switch_time;
45 while (now < switch_time);
47 return now - switch_time + thread_time;
53 #endif /* ! __L4UTIL__INCLUDE__ARCH_X86__THREAD_TIME_H__ */