35 strcpy(
string,
"cpu idle_clocks active_clocks interrupt_clocks");
61 sprintf(
string +
strlen(
string),
"%lu %lu %lu %lu", cpu->
id, idleClocks, activeClocks, interruptClocks);
84 char*
string =
malloc(256);
136 panic(
NULL,
"Failed to initialize performance directory");
142 panic(
NULL,
"Failed to create CPU performance file");
147 panic(
NULL,
"Failed to create memory performance file");
158 panic(
NULL,
"perf_interrupt_begin called while already in interrupt interuptBegin=%llu interruptEnd=%llu",
213 panic(
NULL,
"perf_syscall_begin called while already in syscall syscallBegin=%llu syscallEnd=%llu",
#define CPU_FOR_EACH(cpu)
Macro to iterate over all CPUs.
static uint64_t cpu_amount(void)
Gets the number of identified CPUs.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
uint64_t pmm_free_amount(void)
Retrieves the amount of free physical memory.
uint64_t pmm_used_amount(void)
Retrieves the amount of reserved physical memory.
uint64_t pmm_total_amount(void)
Retrieves the total amount of physical memory managed by the PMM.
thread_t * sched_thread_unsafe(void)
Retrieves the currently running thread without disabling interrupts.
bool sched_is_idle(cpu_t *cpu)
Checks if the CPU is idle.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
static void lock_release(lock_t *lock)
Releases a lock.
static void lock_acquire(lock_t *lock)
Acquires a lock, blocking until it is available.
clock_t sys_time_uptime(void)
Time since boot.
#define errno
Error number variable.
clock_t uptime(void)
System call for retreving the time since boot.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ clock_t
A nanosecond time.
EFI_PHYSICAL_ADDRESS buffer
static dentry_t * cpuFile
static dentry_t * memFile
static uint64_t perf_mem_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static uint64_t perf_cpu_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static dentry_t * perfDir
#define atomic_fetch_add(object, operand)
#define atomic_init(obj, value)
_PUBLIC int sprintf(char *_RESTRICT s, const char *_RESTRICT format,...)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC size_t strlen(const char *s)
_PUBLIC char * strcpy(char *_RESTRICT s1, const char *_RESTRICT s2)
Directory entry structure.
File operations structure.
uint64_t(* read)(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Per-CPU performance context.
clock_t startTime
The time when the process was started.
Per-Thread performance context.
clock_t syscallBegin
The time the current syscall began. Also used to "skip" time spent in interrupts.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.
dentry_t * sysfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted SysFS instance.
dentry_t * sysfs_file_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, const file_ops_t *fileOps, void *private)
Create a new file inside a mounted SysFS instance.