aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-25 10:48:06 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-25 10:48:06 +0000
commit17e7f04c8d144e0e0598464806dcb111ed5386d7 (patch)
tree002284cda156b2516c1d3a67352288741d7cd2e5 /libbb
parente0bcba18eb9c185cefbef2ef05b846f735bd133a (diff)
downloadbusybox-w32-17e7f04c8d144e0e0598464806dcb111ed5386d7.tar.gz
busybox-w32-17e7f04c8d144e0e0598464806dcb111ed5386d7.tar.bz2
busybox-w32-17e7f04c8d144e0e0598464806dcb111ed5386d7.zip
top: optional SMP support by Vineet Gupta (vineetg76 AT gmail.com)
Diffstat (limited to 'libbb')
-rw-r--r--libbb/procps.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index fd19621db..4d9a95b4f 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -219,7 +219,6 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
219#if !ENABLE_FEATURE_FAST_TOP 219#if !ENABLE_FEATURE_FAST_TOP
220 unsigned long vsz, rss; 220 unsigned long vsz, rss;
221#endif 221#endif
222
223 /* see proc(5) for some details on this */ 222 /* see proc(5) for some details on this */
224 strcpy(filename_tail, "/stat"); 223 strcpy(filename_tail, "/stat");
225 n = read_to_buf(filename, buf); 224 n = read_to_buf(filename, buf);
@@ -247,9 +246,12 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
247 "%lu " /* start_time */ 246 "%lu " /* start_time */
248 "%lu " /* vsize */ 247 "%lu " /* vsize */
249 "%lu " /* rss */ 248 "%lu " /* rss */
250 /* "%lu %lu %lu %lu %lu %lu " rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */ 249#if ENABLE_FEATURE_TOP_SMP_PROCESS
251 /* "%u %u %u %u " signal, blocked, sigignore, sigcatch */ 250 "%*s %*s %*s %*s %*s %*s " /*rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */
252 /* "%lu %lu %lu" wchan, nswap, cnswap */ 251 "%*s %*s %*s %*s " /*signal, blocked, sigignore, sigcatch */
252 "%*s %*s %*s %*s " /*wchan, nswap, cnswap, exit_signal */
253 "%d" /*cpu last seen on*/
254#endif
253 , 255 ,
254 sp->state, &sp->ppid, 256 sp->state, &sp->ppid,
255 &sp->pgid, &sp->sid, &tty, 257 &sp->pgid, &sp->sid, &tty,
@@ -257,9 +259,19 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
257 &tasknice, 259 &tasknice,
258 &sp->start_time, 260 &sp->start_time,
259 &vsz, 261 &vsz,
260 &rss); 262 &rss
261 if (n != 11) 263#if ENABLE_FEATURE_TOP_SMP_PROCESS
264 , &sp->last_seen_on_cpu
265#endif
266 );
267
268 if (n < 11)
262 break; 269 break;
270#if ENABLE_FEATURE_TOP_SMP_PROCESS
271 if (n < 11+15)
272 sp->last_seen_on_cpu = 0;
273#endif
274
263 /* vsz is in bytes and we want kb */ 275 /* vsz is in bytes and we want kb */
264 sp->vsz = vsz >> 10; 276 sp->vsz = vsz >> 10;
265 /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */ 277 /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */
@@ -288,7 +300,15 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
288 sp->vsz = fast_strtoul_10(&cp) >> 10; 300 sp->vsz = fast_strtoul_10(&cp) >> 10;
289 /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */ 301 /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */
290 sp->rss = fast_strtoul_10(&cp) << sp->shift_pages_to_kb; 302 sp->rss = fast_strtoul_10(&cp) << sp->shift_pages_to_kb;
303#if ENABLE_FEATURE_TOP_SMP_PROCESS
304 /* (6): rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */
305 /* (4): signal, blocked, sigignore, sigcatch */
306 /* (4): wchan, nswap, cnswap, exit_signal */
307 cp = skip_fields(cp, 14);
308//FIXME: is it safe to assume this field exists?
309 sp->last_seen_on_cpu = fast_strtoul_10(&cp);
291#endif 310#endif
311#endif /* end of !ENABLE_FEATURE_TOP_SMP_PROCESS */
292 312
293 if (sp->vsz == 0 && sp->state[0] != 'Z') 313 if (sp->vsz == 0 && sp->state[0] != 'Z')
294 sp->state[1] = 'W'; 314 sp->state[1] = 'W';
@@ -300,7 +320,6 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
300 sp->state[2] = 'N'; 320 sp->state[2] = 'N';
301 else 321 else
302 sp->state[2] = ' '; 322 sp->state[2] = ' ';
303
304 } 323 }
305 324
306#if ENABLE_FEATURE_TOPMEM 325#if ENABLE_FEATURE_TOPMEM