PatchworkOS
Loading...
Searching...
No Matches
main.c File Reference
#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_stats_t
 
struct  mem_stats_t
 
struct  stats_t
 

Macros

#define SAMPLE_INTERVAL   (CLOCKS_PER_SEC)
 
#define PLOT_WIDTH   20
 

Functions

static uint64_t terminal_columns_get (void)
 
static uint64_t cpu_stat_count_cpus (void)
 
static uint64_t cpu_stat_read (cpu_stats_t *cpuStats, uint64_t cpuAmount)
 
static uint64_t mem_stat_read (mem_stats_t *memStats)
 
static void stats_update (stats_t *stats)
 
static void stat_percentage (clock_t part, clock_t total, uint64_t *whole, uint64_t *thousandths)
 
static void stats_print (stats_t *stats)
 
int main (void)
 

Variables

static uint64_t terminalColumns
 

Macro Definition Documentation

◆ PLOT_WIDTH

#define PLOT_WIDTH   20

Definition at line 12 of file main.c.

◆ SAMPLE_INTERVAL

#define SAMPLE_INTERVAL   (CLOCKS_PER_SEC)

Definition at line 10 of file main.c.

Function Documentation

◆ cpu_stat_count_cpus()

static uint64_t cpu_stat_count_cpus ( void  )
static

Definition at line 67 of file main.c.

References ERR, fclose(), fgets(), file, fopen(), and NULL.

Referenced by main().

◆ cpu_stat_read()

static uint64_t cpu_stat_read ( cpu_stats_t cpuStats,
uint64_t  cpuAmount 
)
static

◆ main()

◆ mem_stat_read()

static uint64_t mem_stat_read ( mem_stats_t memStats)
static

◆ stat_percentage()

static void stat_percentage ( clock_t  part,
clock_t  total,
uint64_t whole,
uint64_t thousandths 
)
static

Definition at line 158 of file main.c.

Referenced by stats_print().

◆ stats_print()

◆ stats_update()

static void stats_update ( stats_t stats)
static

◆ terminal_columns_get()

static uint64_t terminal_columns_get ( void  )
static

Definition at line 16 of file main.c.

References buffer, fflush(), MAX_NAME, printf(), read(), sscanf(), STDIN_FILENO, and stdout.

Variable Documentation

◆ terminalColumns

uint64_t terminalColumns
static

Definition at line 14 of file main.c.

Referenced by main(), and stats_print().