gomd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gomd-devel] <DAEMON> /proc/cpuinfo support: W.I.P.


From: Gian Paolo Ghilardi
Subject: [gomd-devel] <DAEMON> /proc/cpuinfo support: W.I.P.
Date: Tue, 1 Jul 2003 02:26:43 +0200

Hi all.

I'm working on /proc/cpuinfo support in sysInfo class (sysInfo.h/sysInfo.cpp
files).
Now we can get an STL multimap with all the pairs <info,value> parsed from
file /proc/cpuinfo.

Here are the modification (as reported in the CVS).


IN gomd.cpp
(+) added buffer cleanup at line #636 (like other options)
(f) modified call to getCpusLoad(), included in sysInfo class (new version
of this
    functions, in in sysInfo class, has no param)


IN sysInfo.h/sysInfo.cpp
(+) added getInfoMapFromProc() function. It gets a multimap with pairs
<info,value>
    passing an input filename to parseSpecialFile() function included in
util class.
    NOTE: this function is not used at this moment.
(m) modified getCPUNumber() call.
    Now its name is getCpusNumber() and it uses new parseSpecialFile() call
    (included in utils class) to get a map of the pair <info,value> obtained
    from file /proc/cpuinfo
(m) modified getCPULoad() call.
    Now its name is getCpusLoad() and has no param.
    The number of system cpus is obtained from getCpusNumber() function.


IN utils.h/utils.cpp
(+) added parseSpecialFile() function: this function opens a special file
    (i.e. /proc/cpuinfo), parses each line to get a valid pair <info,value>
    and insert each pair in a STL multimap.
    Multimap is a collection of pairs. It is a multimap (not a standard map)
    because pairs may occur more than once (in fact cpuinfo file can
contains
    the info of more than a single cpu: SMP machines have 2+ cpus and each
    cpu has its infos in cpuinfo).
    STL Maps and multimaps are sorted by default (WOW! ;) ).
(-) removed findInFile() function because superseded by new
parseSpecialFile()
    function. Instead of search just a single info (string) in a file
    (i.e. /proc/cpuinfo), now we get a sorted multimap with _all_ the infos
    and related values. Then we can get a info (and its value) in a easier
way by using
    standard find() function of STL multimaps.
(f) fixed comments for writeToFile() functions (now are generic).


I hope you like it.

C++ and STL are great!!! ;)

<rejected>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]