41 lines
979 B
C
41 lines
979 B
C
/*
|
|
* test.h
|
|
* Copyright (C) 2021 light <light@lightdeMBP>
|
|
*
|
|
* Distributed under terms of the MIT license.
|
|
*/
|
|
|
|
#ifndef TEST_H
|
|
#define TEST_H
|
|
#define MaxCache 256
|
|
|
|
//proc/PID/stat
|
|
typedef struct Proc_CPU_Time {
|
|
unsigned long utime; //user time
|
|
unsigned long stime; //kernel time
|
|
} Proc_CPU_Time;
|
|
|
|
//proc/PID/statm,the value should multiply 4
|
|
typedef struct Proc_Mem {
|
|
unsigned long vsz; //Virtual Memory Size, includes all memory that the process can access
|
|
unsigned long rss; //Resident Set Size
|
|
} Proc_Mem;
|
|
|
|
typedef struct Proc_Info {
|
|
unsigned int pid;
|
|
char name[128];
|
|
int point; //0-29
|
|
struct Proc_CPU_Time cpuInfo[30];
|
|
struct Proc_Mem memInfo[30];
|
|
} Proc_Info;
|
|
|
|
void updateMem(unsigned int *all, unsigned int *fre, float *useage);
|
|
|
|
int updateProcInfo(Proc_Info *proc);
|
|
unsigned int* getProcess();
|
|
|
|
int foundProcess(Proc_Info *pList, unsigned int id);
|
|
int assertProcess(Proc_Info *pList, unsigned int id);
|
|
|
|
#endif /* !TEST_H */
|