Obtain the CPU utilization and memory usage in Linux-Linux general technology-Linux programming and kernel information. The following is a detailed description. In Linux, if you want to monitor the running status of a process, such as viewing its CPU usage efficiency and memory usage, you need to read some system information from the/proc directory of the system. Then the analysis results are obtained, especially for embedded applications. The code in this article is obtained from the source code analysis of the top Command, and some modifications are made. The code is successfully debugged in FC6 + GCC4.1. I also gained some insights from this project.
1. Linux is very elegant. If you do this function in Windows, you need to call ActiveX controls. In Linux, you only need to read the text.
2. if you do not know how to implement any functions, you can check the source code and customize the functions required by other software.
3. I want to see more and learn more about technology.
Top Command source code download: http://www.groupsys.com/top/download.shtml
Project download: http://www.cppblog.com/Files/dyj057/mytop.zip
The following code obtains the CPU and memory of the system:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.