From owner-freebsd-bugs Thu Nov 6 10:20:12 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id KAA03027 for bugs-outgoing; Thu, 6 Nov 1997 10:20:12 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id KAA03018; Thu, 6 Nov 1997 10:20:07 -0800 (PST) (envelope-from gnats) Resent-Date: Thu, 6 Nov 1997 10:20:07 -0800 (PST) Resent-Message-Id: <199711061820.KAA03018@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, dnelson@emsphone.com Received: from dan.emsphone.com (dan@dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id KAA02832 for ; Thu, 6 Nov 1997 10:16:21 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.8.6/8.8.6) id MAA14661; Thu, 6 Nov 1997 12:16:17 -0600 (CST) Message-Id: <199711061816.MAA14661@dan.emsphone.com> Date: Thu, 6 Nov 1997 12:16:17 -0600 (CST) From: dnelson@emsphone.com Reply-To: dnelson@emsphone.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/4957: /bin/top doesn't sort idle processes correctly Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 4957 >Category: bin >Synopsis: /bin/top doesn't sort idle processes correctly >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Nov 6 10:20:02 PST 1997 >Last-Modified: >Originator: Dan Nelson >Organization: Executive Marketing Services, Inc. >Release: FreeBSD 2.2-970701-RELENG i386 >Environment: >Description: /usr/bin/top doesn't sort idle processes by total CPU usage. The current code is sorting by cpticks, which gets zeroed every second; sort of useless for sorting. >How-To-Repeat: Run top; make sure I)dle processes are shown, see that they are not sorted on CPU usage >Fix: Don't sort on cpticks; instead sort on what top actually prints in the TIME column; rtime.tv_sec. Index: machine.c =================================================================== RCS file: /home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.3.2.2 diff -b -u -p -r1.3.2.2 machine.c --- machine.c 1997/09/27 21:30:16 1.3.2.2 +++ machine.c 1997/11/06 17:45:17 @@ -726,8 +726,8 @@ struct proc **pp2; /* compare percent cpu (pctcpu) */ if ((lresult = PP(p2, p_pctcpu) - PP(p1, p_pctcpu)) == 0) { - /* use cpticks to break the tie */ - if ((result = PP(p2, p_cpticks) - PP(p1, p_cpticks)) == 0) + /* use CPU usage to break the tie */ + if ((result = PP(p2, p_rtime).tv_sec - PP(p1, p_rtime).tv_sec) == 0) { /* use process state to break the tie */ if ((result = sorted_state[(unsigned char) PP(p2, p_stat)] - >Audit-Trail: >Unformatted: