1 | #include <stdlib.h>
|
---|
2 |
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <unistd.h>
|
---|
5 |
|
---|
6 | #include <OS.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | void
|
---|
10 | print_system_info(system_info& infoSystem)
|
---|
11 | {
|
---|
12 | get_system_info(&infoSystem);
|
---|
13 | printf("------- memory info ------------\n");
|
---|
14 | printf(" available memory: \t%ld MB\n", (infoSystem.max_pages * 4096) / (1024 * 1024));
|
---|
15 | printf(" used memory: \t\t%ld MB\n", (infoSystem.used_pages * 4096) / (1024 * 1024));
|
---|
16 | printf(" free memory: \t\t%ld MB\n", ((infoSystem.max_pages - infoSystem.used_pages) * 4096) / (1024 * 1024));
|
---|
17 | printf("--------------------------------\n");
|
---|
18 | }
|
---|
19 |
|
---|
20 |
|
---|
21 | int
|
---|
22 | main()
|
---|
23 | {
|
---|
24 | system_info info;
|
---|
25 |
|
---|
26 | while (true) {
|
---|
27 | printf("\033[H\033[J"); // clear screen
|
---|
28 | print_system_info(info);
|
---|
29 | snooze(200000);
|
---|
30 | }
|
---|
31 |
|
---|
32 | return 0;
|
---|
33 | }
|
---|