61 strcpy(
string,
"cpu idle_clocks active_clocks interrupt_clocks");
89 sprintf(
string +
strlen(
string),
"%lu %lu %lu %lu", cpu->
id, idleClocks, activeClocks, interruptClocks);
98 size_t length =
strlen(
string);
112 char*
string =
malloc(256);
155 panic(
NULL,
"Failed to initialize performance directory");
161 panic(
NULL,
"Failed to create CPU performance file");
166 panic(
NULL,
"Failed to create memory performance file");
177 LOG_WARN(
"unexpected call to perf_interrupt_begin()\n");
236 LOG_WARN(
"unexpected call to perf_syscall_begin()\n");
EFI_PHYSICAL_ADDRESS buffer
#define CLI_SCOPE()
Macro to increment CLI depth for the duration of the current scope.
#define SELF_PTR(ptr)
Macro to get a pointer to a percpu variable on the current CPU.
#define SELF
Macro to access data in the current cpu.
#define CPU_PTR(id, ptr)
Macro to get a pointer to a percpu variable on a specific CPU.
#define PERCPU_DEFINE_CTOR(type, name)
Macro to define a percpu variable with a constructor.
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_file_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, const file_ops_t *fileOps, void *data)
Create a new file inside a mounted devfs instance.
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
Create a new directory 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_total_pages(void)
Get the total number of physical pages.
size_t pmm_used_pages(void)
Get the number of used physical pages.
size_t pmm_avail_pages(void)
Get the number of available physical pages.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
static thread_t * thread_current_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.
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)
A simple ticket lock implementation.
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.