[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdeextragear-2/kcpuload/kcpuload
From: Ben Burton <bab () debian ! org>
Date: 2005-03-25 8:47:05
Message-ID: 20050325084705.B68D948F () office ! kde ! org
[Download RAW message or body]
CVS commit by benb:
Make SMP support work under linux 2.6 as well as linux 2.4.
M +16 -0 kcpuproc.cpp 1.4
M +16 -0 kcpuproc.h 1.2
--- kdeextragear-2/kcpuload/kcpuload/kcpuproc.cpp #1.3:1.4
@@ -61,4 +61,7 @@
* user_ticks nice_ticks system_ticks idle_ticks
*
+ * We also allow sets of seven numbers instead of four (as provided by
+ * the 2.6 kernel); the last three of these numbers are ignored.
+ *
* BSD
* ---
@@ -108,5 +111,7 @@ KCPUProc::KCPUProc() {
fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
+ ignoreLine();
fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);
+ ignoreLine();
if (strcmp(tagCPU0, tag) != 0)
@@ -167,5 +172,7 @@ void KCPUProc::readLoad() {
#ifdef Q_OS_LINUX
fscanf(fd, "%32s %d %d %d %d", tag, &cUT, &cNT, &cST, &cIT);
+ ignoreLine();
fscanf(fd, "%32s %d %d %d %d", tag, &cUT0, &cNT0, &cST0, &cIT0);
+ ignoreLine();
fscanf(fd, "%32s %d %d %d %d", tag, &cUT1, &cNT1, &cST1, &cIT1);
#endif
@@ -231,2 +238,11 @@ void KCPUProc::readLoad() {
}
+// ========== Linux-specific (begin) ==========
+#ifdef Q_OS_LINUX
+void KCPUProc::ignoreLine() {
+ int c = getc(fd);
+ while (c != '\n' && c != EOF)
+ c = getc(fd);
+}
+#endif
+// ========== Linux-specific (end) ==========
--- kdeextragear-2/kcpuload/kcpuload/kcpuproc.h #1.1:1.2
@@ -143,4 +143,20 @@ private:
#endif
// ========== Linux-specific (end) ==========
+
+private:
+ /**
+ * OS-specific helper routines.
+ */
+
+ // ========== Linux-specific (begin) ==========
+#ifdef Q_OS_LINUX
+ /**
+ * Read to the end of the current line in /proc/stat.
+ * The final newline will be read also.
+ * It is assumed that /proc/stat is already opened for reading.
+ */
+ void ignoreLine();
+#endif
+ // ========== Linux-specific (end) ==========
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic