20#include "pedigree/kernel/process/Process.h"
21#include "pedigree/kernel/process/Thread.h"
22#include "pedigree/kernel/process/TimeTracker.h"
23#include "pedigree/kernel/processor/Processor.h"
24#include "pedigree/kernel/processor/ProcessorInformation.h"
26void TimeTracker::initialise(
bool entryInterruptsAlreadyDisabled) {
39 if (!threadProcess || (m_pProcess && m_pProcess != threadProcess)) {
44 m_pProcess = threadProcess;
47 if (entryInterruptsAlreadyDisabled) {
49 KernelTimeTransition::handler());
51 m_pThread->
transitionTime(KernelTimeTransition::interrupted(m_bFromUserspace),
52 KernelTimeTransition::handler());
57#if PEDIGREE_BENCHMARK_SYSCALL_TIMING
58 if (!m_pProcess || !m_pThread || !m_bFromUserspace || m_bSyscallAttributed ||
59 !m_pProcess->benchmarkSyscallTimingEnabled()) {
63 const size_t slot = Process::syscallTimingSlot(rawNumber);
64 m_pProcess->recordSyscallTimingCall(slot);
65 m_PreviousSyscallTimingSlot = m_pThread->installSyscallTimingSlot(slot);
66 m_bSyscallAttributed =
true;
73 Thread* thread = m_pThread;
74 if (!m_pProcess || !thread)
84 KernelTimeTransition::resumed(m_bFromUserspace));
85#if PEDIGREE_BENCHMARK_SYSCALL_TIMING
86 restoreSyscallTiming(thread);
91 Thread* thread = m_pThread;
92 if (!m_pProcess || !thread)
102 thread->
transitionTime(KernelTimeTransition::handler(), KernelTimeTransition::handler());
103#if PEDIGREE_BENCHMARK_SYSCALL_TIMING
104 restoreSyscallTiming(thread);
108#if PEDIGREE_BENCHMARK_SYSCALL_TIMING
109void TimeTracker::restoreSyscallTiming(
Thread* thread) {
110 if (m_bSyscallAttributed) {
111 thread->restoreSyscallTimingSlot(m_PreviousSyscallTimingSlot);
112 m_bSyscallAttributed =
false;
static ProcessorInformation & information()
ALWAYS_INLINE void transitionTimeAtInterruptReturn(CpuTimeMode from, CpuTimeMode to)
Process * getParent() const
void transitionTime(CpuTimeMode from, CpuTimeMode to, bool interruptsAlreadyDisabled=false)
void attributeSyscall(size_t rawNumber)