read process info

This commit is contained in:
veypi
2021-07-20 16:55:01 +08:00
parent 208f4aeac2
commit d936f5f514
4 changed files with 181 additions and 15 deletions
+24 -2
View File
@@ -7,12 +7,34 @@
#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;
#include<math.h>
//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;
double get_sqrt(double var1);
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 */