47 lines
941 B
C
47 lines
941 B
C
/*
|
|
* main.c
|
|
* Copyright (C) 2021 light <light@lightdeMBP>
|
|
*
|
|
* Distributed under terms of the MIT license.
|
|
*/
|
|
|
|
#include<stdio.h>
|
|
#include"./include/test.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
struct memGlobal {
|
|
unsigned int All;
|
|
float Useage;
|
|
unsigned int Free;
|
|
} memG;
|
|
|
|
struct cpuGlobal {
|
|
float Useage;
|
|
} cpuG;
|
|
|
|
struct Proc_Info pList[MaxCache];
|
|
|
|
int main()
|
|
{
|
|
unsigned int *ids;
|
|
ids = getProcess();
|
|
int i, index;
|
|
pList[3].pid = 2;
|
|
for(i=0;i<128;i++) {
|
|
index = foundProcess(pList, *ids);
|
|
if (index == -1) {
|
|
index = assertProcess(pList, *ids);
|
|
}
|
|
updateProcInfo(&pList[index]);
|
|
// printf("/proc/%d %d \n", *ids, index);
|
|
ids ++;
|
|
if (*ids == 0) {
|
|
break;
|
|
}
|
|
}
|
|
updateMem(&memG.All, &memG.Free, &memG.Useage);
|
|
printf("mem: all %u free: %u usage: %f\n", memG.All, memG.Free, memG.Useage);
|
|
return 0;
|
|
}
|
|
|