Страница 1 из 1

top-3.8b1

Добавлено: 2008-11-05 10:09:14
Гость
Боян, но... кто пользуется? Когда commit'тить будут?
http://docs.FreeBSD.org/cgi/mid.cgi?200 ... 20.GA80250
svn co svn://svn.freebsd.org/base/user/edwin/top/top-3.8b1

Код: Выделить всё

> top -Pbu
last pid: 70205;  load avg:  0.52,  0.42,  1.13;    up 0+16:40:47      09:18:04
166 processes: 3 running, 161 sleeping, 1 stopped, 1 waiting
CPU 0:  12.8% user,  0.0% nice, 21.8% system,  0.0% interrupt, 65.4% idle
CPU 1:  36.1% user,  0.0% nice, 27.1% system,  0.0% interrupt, 36.8% idle
Kern:   9283 ctxsw, 39315 trap, 53 intr, 30434 soft, 275 fork, 38750 flt, 2 pgin, 38341 fr
Mem:    346M Active, 119M Inact, 1123M Wired, 29M Cache, 213M Buf, 358M Free
Swap:   10G Total, 10G Free

   PID    UID THR PRI NICE  SIZE   RES STATE  FLG C   TIME    CPU COMMAND
  1274   1001   1  44    0  327M  282M select +   0  17:27  0.00% Xorg
 68343      0   1  76  i31 7176K 1712K wait   +   0   0:00  0.00% sh
 70205      0   1 171  i31 2180K  884K CPU0   +   0   0:00  0.00% make
 68319      0   1  76  i31 2180K 1020K select +   0   0:00  0.00% make
 69928   1001   1  44    0 8248K 1764K CPU1   +   1   0:00  0.00% top
  1403   1001   1  44    0  163M   87M select +   1   3:25  0.00% emacs
 59034   1001   1  44    0 8940K 1588K select +   1   0:11  0.00% xmp
 31563   1001   5  76    0  180M   74M ucond  +   0   0:09  0.00% xulrunner-bin
  1232   1001   1  44    0   30M   13M select s   1   0:08  0.00% screen
никто не пилил realtime priority? edwin@ почему-то забыл о rtprio(1) и как это отображал старый top. За невладением C у мя не полуичлось сделать красивого патчика. ;\

только вот такой уродливый:

Код: Выделить всё

Index: contrib/top/display.c
===================================================================
--- contrib/top/display.c	(revision 184642)
+++ contrib/top/display.c	(working copy)
@@ -1167,7 +1167,7 @@
 
     /* print tag */
     if (num_cpus == 1)
-	strcpy(scpu, "CPU: ");
+	strcpy(scpu, "CPU:   ");
     else
 	sprintf(scpu, "CPU %d: ", cpu);
     display_write(0, y_cpustates + cpu, 0, 0, scpu);
@@ -1312,7 +1312,7 @@
 }
 
 /*
- *  *_kernel(stats) - print "Kernel: " followed by the kernel summary string
+ *  *_kernel(stats) - print "Kern: " followed by the kernel summary string
  *
  *  Assumptions:  cursor is on "lastline", the previous line
  */
@@ -1323,7 +1323,7 @@
 {
     if (num_kernel > 0)
     {
-	display_write(0, y_kernel, 0, 0, "Kernel: ");
+	display_write(0, y_kernel, 0, 0, "Kern: ");
 
 	/* format and print the kernel summary */
 	summary_format(x_kernel, y_kernel, stats, kernel_names, kernel_cidx);
Index: usr.bin/top/machine.c
===================================================================
--- usr.bin/top/machine.c	(revision 184642)
+++ usr.bin/top/machine.c	(working copy)
@@ -617,7 +617,59 @@
 fmt_nice(char *buf, int sz, struct kinfo_proc *pp)
 
 {
-    return snprintf(buf, sz, "%4d", PP(pp, nice) - NZERO);
+	const char *fifo, *kthread;
+	int rtpri;
+
+	fifo = PRI_NEED_RR(PP(pp, pri.pri_class)) ? "" : "F";
+	kthread = (PP(pp, flag) & P_KTHREAD) ? "k" : "";
+	switch (PRI_BASE(PP(pp, pri.pri_class))) {
+	case PRI_ITHD:
+		return snprintf(buf, sz, "-");
+	case PRI_REALTIME:
+		/*
+		 * XXX: the kernel doesn't tell us the original rtprio and
+		 * doesn't really know what it was, so to recover it we
+		 * must be more chummy with the implementation than the
+		 * implementation is with itself.  pri_user gives a
+		 * constant "base" priority, but is only initialized
+		 * properly for user threads.  pri_native gives what the
+		 * kernel calls the "base" priority, but it isn't constant
+		 * since it is changed by priority propagation.  pri_native
+		 * also isn't properly initialized for all threads, but it
+		 * is properly initialized for kernel realtime and idletime
+		 * threads.  Thus we use pri_user for the base priority of
+		 * user threads (it is always correct) and pri_native for
+		 * the base priority of kernel realtime and idletime threads
+		 * (there is nothing better, and it is usually correct).
+		 *
+		 * The field width and thus the buffer are too small for
+		 * values like "kr31F", but such values shouldn't occur,
+		 * and if they do then the tailing "F" is not displayed.
+		 */
+		rtpri = ((PP(pp, flag) & P_KTHREAD) ? PP(pp, pri.pri_native) :
+		    PP(pp, pri.pri_user)) - PRI_MIN_REALTIME;
+		if (rtpri < 10)
+			return snprintf(buf, sz, "%2sr%d%s", kthread, rtpri, fifo);
+		else
+			return snprintf(buf, sz, "%1sr%d%s", kthread, rtpri, fifo);
+		break;
+	case PRI_TIMESHARE:
+		if (PP(pp, flag) & P_KTHREAD)
+			return snprintf(buf, sz, "-");
+		return snprintf(buf, sz, "%4d", PP(pp, nice) - NZERO);
+		break;
+	case PRI_IDLE:
+		/* XXX: as above. */
+		rtpri = ((PP(pp, flag) & P_KTHREAD) ? PP(pp, pri.pri_native) :
+		    PP(pp, pri.pri_user)) - PRI_MIN_IDLE;
+		if (rtpri < 10)
+			return snprintf(buf, sz, "%2si%d%s", kthread, rtpri, fifo);
+		else
+			return snprintf(buf, sz, "%1si%d%s", kthread, rtpri, fifo);
+		break;
+	default:
+		return snprintf(buf, sz, "?");
+	}
 }
 
 int

Re: top-3.8b1

Добавлено: 2008-11-05 12:09:38
gonzo111
Гость, Может ты б зарегился на форуме хотя бы?

Re: top-3.8b1

Добавлено: 2008-11-05 12:35:27
Alex Keda
я поюзал, как-то невпечатлило...

Re: top-3.8b1

Добавлено: 2008-11-05 13:25:42
Гость
OOoops!
Гость писал(а):

Код: Выделить всё

+	case PRI_ITHD:
+		return snprintf(buf, sz, "-");
[...]
+	case PRI_TIMESHARE:
+		if (PP(pp, flag) & P_KTHREAD)
+			return snprintf(buf, sz, "-");
тут должно быть " -", т.е. 3 пробела перед минусом, иначе top -S начнет колбасить.