39 strcpy(
string,
"cpu idle_clocks active_clocks interrupt_clocks");
65 sprintf(
string +
strlen(
string),
"%lu %lu %lu %lu", cpu->
id, idleClocks, activeClocks, interruptClocks);
74 size_t length =
strlen(
string);
88 char*
string =
malloc(256);
141 panic(
NULL,
"Failed to initialize performance directory");
147 panic(
NULL,
"Failed to create CPU performance file");
152 panic(
NULL,
"Failed to create memory performance file");
163 LOG_WARN(
"unexpected call to perf_interrupt_begin()\n");
220 LOG_WARN(
"unexpected call to perf_syscall_begin()\n");
void interrupt_disable(void)
Disable interrupts and increment the disableDepth.
void interrupt_enable(void)
Decrement the CLI depth and enable interrupts if depth reaches zero and interrupts were previously en...
static uint16_t cpu_amount(void)
Gets the number of identified CPUs.
#define CPU_FOR_EACH(cpu)
Macro to iterate over all CPUs.
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted devfs instance.
dentry_t * devfs_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 devfs instance.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_WARN(format,...)
size_t pmm_free_amount(void)
Retrieves the amount of free physical memory.
size_t pmm_total_amount(void)
Retrieves the total amount of physical memory managed by the PMM.
size_t pmm_used_amount(void)
Retrieves the amount of reserved physical memory.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
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 currently 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.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
#define ENOMEM
Out of memory.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
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 size_t perf_cpu_read(file_t *file, void *buffer, size_t count, size_t *offset)
static dentry_t * memFile
static dentry_t * perfDir
static size_t perf_mem_read(file_t *file, void *buffer, size_t count, size_t *offset)
#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.
size_t(* read)(file_t *file, void *buffer, size_t count, size_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.