|
PatchworkOS
28a9544
A non-POSIX operating system.
|
#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/io.h>#include <sys/proc.h>#include <threads.h>#include <time.h>Go to the source code of this file.
Data Structures | |
| struct | cpu_perfs_t |
| struct | mem_perfs_t |
| struct | proc_perfs_t |
| struct | perfs_t |
Macros | |
| #define | SAMPLE_INTERVAL (CLOCKS_PER_SEC) |
Enumerations | |
| enum | sort_mode_t { SORT_PID , SORT_MEMORY , SORT_CPU } |
Functions | |
| static void | terminal_size_get (void) |
| static uint64_t | cpu_perf_count_cpus (void) |
| static uint64_t | cpu_perf_read (cpu_perfs_t *cpuPerfs) |
| static uint64_t | mem_perf_read (mem_perfs_t *memPerfs) |
| static proc_perfs_t * | proc_perfs_read (uint64_t *procAmount) |
| static void | calculate_cpu_percentages (perfs_t *perfs) |
| static int | compare_by_pid (const void *a, const void *b) |
| static int | compare_by_memory (const void *a, const void *b) |
| static int | compare_by_cpu (const void *a, const void *b) |
| static void | sort_processes (perfs_t *perfs) |
| static void | perfs_update (perfs_t *perfs) |
| static void | perf_percentage (clock_t part, clock_t total, uint64_t *whole, uint64_t *thousandths) |
| static void | perfs_print (perfs_t *perfs) |
| int | main (void) |
Variables | |
| static uint64_t | terminalColumns |
| static uint64_t | terminalRows |
| static uint64_t | processScrollOffset = 0 |
| static clock_t | lastSampleTime = 0 |
| static uint64_t | cpuAmount = 0 |
| static sort_mode_t | currentSortMode = SORT_CPU |
| #define SAMPLE_INTERVAL (CLOCKS_PER_SEC) |
| enum sort_mode_t |
|
static |
Definition at line 283 of file main.c.
References proc_perfs_t::cpuPercent, proc_perfs_t::kernelClocks, proc_perfs_t::pid, perfs_t::prevProcAmount, perfs_t::prevProcPerfs, perfs_t::procAmount, perfs_t::procPerfs, SAMPLE_INTERVAL, and proc_perfs_t::userClocks.
Referenced by perfs_update().
|
static |
Definition at line 318 of file main.c.
References proc_perfs_t::cpuPercent.
Referenced by sort_processes().
|
static |
Definition at line 311 of file main.c.
References proc_perfs_t::userKiB.
Referenced by sort_processes().
|
static |
Definition at line 304 of file main.c.
References proc_perfs_t::pid.
Referenced by sort_processes().
|
static |
|
static |
Definition at line 122 of file main.c.
References cpu_perfs_t::activeClocks, cpuAmount, ERR, fclose(), fgets(), file, fopen(), cpu_perfs_t::id, cpu_perfs_t::idleClocks, cpu_perfs_t::interruptClocks, NULL, and sscanf().
Referenced by perfs_update().
| int main | ( | void | ) |
Definition at line 714 of file main.c.
References abort(), calloc(), cpu_perf_count_cpus(), cpuAmount, perfs_t::cpuPerfs, ERR, EXIT_FAILURE, free(), perfs_t::memPerfs, NULL, perfs_print(), perfs_update(), perfs_t::prevCpuPerfs, perfs_t::prevProcPerfs, printf(), perfs_t::procPerfs, strlen(), terminal_size_get(), and terminalColumns.
|
static |
Definition at line 154 of file main.c.
References ERR, fclose(), file, fopen(), mem_perfs_t::freeKiB, fscanf(), NULL, PAGE_SIZE, mem_perfs_t::totalKiB, and mem_perfs_t::usedKiB.
Referenced by perfs_update().
|
static |
Definition at line 450 of file main.c.
Referenced by perfs_print().
|
static |
Definition at line 465 of file main.c.
References cpu_perfs_t::activeClocks, proc_perfs_t::cmdline, cpuAmount, proc_perfs_t::cpuPercent, perfs_t::cpuPerfs, currentSortMode, fflush(), mem_perfs_t::freeKiB, cpu_perfs_t::idleClocks, cpu_perfs_t::interruptClocks, perfs_t::memPerfs, perf_percentage(), proc_perfs_t::pid, perfs_t::prevCpuPerfs, printf(), perfs_t::procAmount, processScrollOffset, perfs_t::procPerfs, SORT_CPU, SORT_MEMORY, SORT_PID, stdout, strcat(), strcpy(), strlen(), strncpy(), terminalColumns, terminalRows, proc_perfs_t::threadCount, mem_perfs_t::totalKiB, and proc_perfs_t::userKiB.
Referenced by main().
|
static |
Definition at line 345 of file main.c.
References abort(), calculate_cpu_percentages(), clock(), cpu_perf_read(), cpuAmount, perfs_t::cpuPerfs, currentSortMode, ERR, exit(), free(), lastSampleTime, mem_perf_read(), memcpy(), perfs_t::memPerfs, NULL, poll1(), POLLIN, perfs_t::prevCpuPerfs, perfs_t::prevProcAmount, perfs_t::prevProcPerfs, printf(), proc_perfs_read(), perfs_t::procAmount, processScrollOffset, perfs_t::procPerfs, read(), SAMPLE_INTERVAL, SORT_CPU, SORT_MEMORY, SORT_PID, sort_processes(), and STDIN_FILENO.
Referenced by main().
|
static |
Definition at line 182 of file main.c.
References atoi, buffer, close(), proc_perfs_t::cmdline, proc_perfs_t::cpuPercent, ERR, fclose(), fopen(), fread(), free(), fscanf(), getdents(), proc_perfs_t::kernelClocks, MAX_PATH, NULL, open(), PAGE_SIZE, proc_perfs_t::pid, realloc(), snprintf(), proc_perfs_t::startClocks, strcmp(), proc_perfs_t::threadCount, proc_perfs_t::userClocks, and proc_perfs_t::userKiB.
Referenced by perfs_update().
|
static |
Definition at line 329 of file main.c.
References compare_by_cpu(), compare_by_memory(), compare_by_pid(), currentSortMode, perfs_t::procAmount, perfs_t::procPerfs, qsort(), SORT_CPU, SORT_MEMORY, and SORT_PID.
Referenced by perfs_update().
|
static |
Definition at line 28 of file main.c.
References buffer, fflush(), MAX_NAME, printf(), read(), sscanf(), STDIN_FILENO, stdout, terminalColumns, and terminalRows.
Referenced by main().
|
static |
Definition at line 17 of file main.c.
Referenced by cpu_perf_read(), main(), perfs_print(), and perfs_update().
|
static |
Definition at line 26 of file main.c.
Referenced by perfs_print(), perfs_update(), and sort_processes().
|
static |
Definition at line 16 of file main.c.
Referenced by perfs_update().
|
static |
Definition at line 14 of file main.c.
Referenced by perfs_print(), and perfs_update().
|
static |
Definition at line 12 of file main.c.
Referenced by main(), perfs_print(), and terminal_size_get().
|
static |
Definition at line 13 of file main.c.
Referenced by perfs_print(), and terminal_size_get().