My Operating Systems professor has assigned me a project to develop a C program that reads information from the /proc/stat
file and displays CPU usage in real time in a simple manner. However, I wasn’t given much detail on how to carry out this task.
Could you help me understand what this project entails and how I can develop it? Here are my specific questions:
-
What information do I need to extract from
/proc/stat
to calculate CPU usage?- I understand that
/proc/stat
contains CPU statistics, but what specific fields should I consider to calculate CPU usage?
- I understand that
-
How should I structure my C program to read and process information from
/proc/stat
?- What standard C library functions should I use to open, read, and process the file?
- How can I handle the read data to calculate CPU usage?
-
How can I update the screen to display CPU usage in real time?
- What techniques can I use to make the program update CPU usage information at regular intervals?
-
What are the steps to test my program?
- How can I verify that the program is working correctly and displaying accurate CPU usage information?
-
What should the project requirements be in order for me to analyse, design, and implement a solution to the project?
- How it should be his expected
input
,output
pre
andpost conditions
of the solution implementation?
I appreciate any guidance or code examples you can provide to get started on this project. Thanks in advance!