PatchworkOS  28a9544
A non-POSIX operating system.
Loading...
Searching...
No Matches
perf.h
Go to the documentation of this file.
1#pragma once
2
4#include <kernel/sync/lock.h>
5
6#include <time.h>
7
8typedef struct cpu cpu_t;
9typedef struct thread thread_t;
10
57
62typedef struct
63{
64 _Atomic(clock_t) userClocks;
66 kernelClocks;
69
82
89
96
103
107void perf_init(void);
108
116void perf_interrupt_begin(cpu_t* self);
117
125void perf_interrupt_end(cpu_t* self);
126
132void perf_syscall_begin(void);
133
139void perf_syscall_end(void);
140
void perf_cpu_ctx_init(perf_cpu_ctx_t *ctx)
Initializes a per-CPU performance context, must be called on the CPU that owns the context.
Definition perf.c:108
void perf_syscall_end(void)
Called at the end of a syscall to update process performance data.
Definition perf.c:225
void perf_interrupt_begin(cpu_t *self)
Called at the beginning of an interrupt to update cpu performance data.
Definition perf.c:151
void perf_interrupt_end(cpu_t *self)
Called at the end of an interrupt to update cpu performance data.
Definition perf.c:187
void perf_syscall_begin(void)
Called at the beginning of a syscall to update process performance data.
Definition perf.c:205
void perf_process_ctx_init(perf_process_ctx_t *ctx)
Initializes a per-process performance context.
Definition perf.c:118
void perf_thread_ctx_init(perf_thread_ctx_t *ctx)
Initializes a per-thread performance context.
Definition perf.c:125
void perf_init(void)
Initializes the performance driver.
Definition perf.c:131
__UINT64_TYPE__ clock_t
A nanosecond time.
Definition clock_t.h:13
CPU structure.
Definition cpu.h:63
A simple ticket lock implementation.
Definition lock.h:43
Per-CPU performance context.
Definition perf.h:49
lock_t lock
Definition perf.h:55
clock_t activeClocks
Definition perf.h:50
clock_t interruptEnd
Definition perf.h:54
clock_t idleClocks
Definition perf.h:52
clock_t interruptBegin
Definition perf.h:53
clock_t interruptClocks
Definition perf.h:51
_Atomic(clock_t) kernelClocks
Total kernel mode CPU time used by this process, does not include interrupt time.
clock_t startTime
The time when the process was started.
Definition perf.h:67
_Atomic(clock_t) userClocks
Total user mode CPU time used by this process.
Per-Thread performance context.
Definition perf.h:78
clock_t syscallBegin
The time the current syscall began. Also used to "skip" time spent in interrupts.
Definition perf.h:79
clock_t syscallEnd
Definition perf.h:80
Thread of execution structure.
Definition thread.h:55