Logo Search packages:      
Sourcecode: kcpuload version File versions  Download package

KCPUProc::KCPUProc (  ) 

Constructor.

In the constructor, a set of initial CPU tick readings are taken and SMP support is determined.

Definition at line 76 of file kcpuproc.cpp.

References cIT, cIT0, cIT1, IT, IT0, IT1, readLoad(), smp, tot, tot0, tot1, UT, and UT0.

                   {
    smp = false;
    UT = ST = NT = IT = 0;
    UT0 = ST0 = NT0 = IT0 = 0;
    UT1 = ST1 = NT1 = IT1 = 0;
    cUT = cST = cNT = cIT = 0;
    cUT0 = cST0 = cNT0 = cIT0 = 0;
    cUT1 = cST1 = cNT1 = cIT1 = 0;
    tot = tot0 = tot1 = 0;

    // Look for SMP support and take a current tick reading.

    // ========== BSD-specific (begin) ==========
#ifdef Q_OS_BSD4
    smp = false;
    readLoad();
    return;
#endif
    // ========== BSD-specific (end) ==========

    // ========== Linux-specific (begin) ==========
#ifdef Q_OS_LINUX
    if ((fd = fopen("/proc/stat", "r")) == 0)
        return;

    fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
    fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);

    if (strcmp(tagCPU0, tag) != 0)
        return;

    fscanf(fd, "%32s %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);

    if (strcmp(tagCPU1, tag) == 0)
        smp = true;
#endif
    // ========== Linux-specific (end) ==========
}


Generated by  Doxygen 1.6.0   Back to index