An Introduction To Embedded Tk (page 29 of 32)

[Previous Page][Next Page][Table of Contents]

12.3 A Real-Time Performance Monitor For Linux

The perfmon program is a system performance monitor for the Linux operating system. It uses bar graphs to shows the amount of memory, swap space, CPU time currently being used. The display is updated 10 times per second. There are two source code files for this application: perfmon.c and perfmon.tcl.

The main display of the perfmon program is implemented using a Tcl/Tk canvas widget. But for efficiency's sake, the logic that computes the current memory, swap space, and CPU usages is all coded in C. The C code obtains the system performance data by reading the files /proc/stat and /proc/meminfo. It then processes this information into the desired preformance measurements and makes appropriate changes to the Tcl/Tk bar graphs using ET() function calls.

On a 90MHz Pentium and with an update frequency of 10 times per second, the prefmon program uses a negligible amount of the CPU time. So in addition to being a nifty desktop utility for a Linux workstation, this example demonstrates that Tcl/Tk applications can be very efficient.

[Next Page][Table of Contents]