util.h (810B)
1#pragma once 2 3#include <sys/types.h> 4#include <stdbool.h> 5#include <stdint.h> 6 7#define ARRLEN(x) (sizeof(x) / sizeof((x)[0])) 8#define MIN(a,b) ((a) > (b) ? (b) : (a)) 9 10#define TARGET_CORE 2 11#define SECONDARY_CORE 3 12 13struct ipc { 14 pthread_mutex_t lock; 15 pthread_cond_t sig_parent; 16 bool has_sig_parent; 17 pthread_cond_t sig_child; 18 bool has_sig_child; 19 bool init; 20}; 21 22void hexdump(void *data, int len); 23 24bool pin_process(pid_t pid, int cpu, bool assert); 25 26int read_stat_core(pid_t pid); 27int pgrep(const char *cmd); 28 29void print_counts(uint8_t *counts); 30void print_counts_raw(uint8_t *counts); 31 32struct ipc *ipc_alloc(void); 33void ipc_free(struct ipc *ipc); 34void ipc_signal_child(struct ipc *ipc); 35void ipc_wait_child(struct ipc *ipc); 36void ipc_signal_parent(struct ipc *ipc); 37void ipc_wait_parent(struct ipc *ipc);