📄 readme.top
字号:
Credit for this belongs to:Jim / James C. Warner, <warnerjc@worldnet.att.net>----------------------------------Ok, ok, I yield -- most of what follows has been removed from the manual pageand packaged separately as this README (hey, it was only TEMPORARY insanity).Of course, that means that now absolutely nobody will ever read it.This is probably a good thing...## Table of Contents ---------------------------------------------------## # the only darn thing that wasn't in the man page CUSTOMIZING the Sources # the following carry their original topic numbers DIFFERENCES / New Features Interface Etiquette Expanded Configurable Display Support Enhanced Field/Column Management Customization Flexibility NOTES and Rantings The top Binary Comparing Performance Cost of Stuff The top Sources EXAMPLES of Windows The 'A' Mode Command Toggle STACKIN' & WHACKIN' Windows ALL TOGETHER Now, Window(s)## CUSTOMIZING the Sources ---------------------------------------------##Listed below are the conditionals available should you wish to recompilethis top. The author's favorite is: PRETEND4CPUS.That's the #define allowing you to simulate an SMP environment, and(perhaps) impress your friends. It's currently set to display fourseparate CPUs, but could easily be changed. Caution: do NOT use this provision in an effort to impress someone who truly possesses such a machine! The fact that all 4 CPUs show the same dynamic results will likely have the opposite effect.//#define ATEOJ_REPORT /* report a bunch of stuff, at end-of-job *///#define CASEUP_HEXES /* show any hex values in upper case *///#define CASEUP_SCALE /* show scaled time/num suffix upper case *///#define CASEUP_SUMMK /* show memory summary kilobytes with 'K' *///#define POSIX_CMDLIN /* use '[ ]' for kernel threads, not '( )' *///#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) *///#define PRETEND4CPUS /* pretend we're smp with 4 ticsers (sic) *///#define PRETENDNOCAP /* use a terminal without essential caps *///#define SORT_SUPRESS /* *attempt* to reduce qsort overhead *///#define STDOUT_IOLBF /* disable our own stdout _IOFBF override *///#define USE_LIB_STA3 /* use lib status (3 ch) vs. proc_t (1 ch) *///#define WARN_NOT_SMP /* restrict '1' & 'I' commands to true smp */## 6. DIFFERENCES / New Features ---------------------------------------## The following summarizes differences between this top and your former top. It was originally based on procps-2.0.7. However, except for the separate/summary CPU toggle, all of these differ- ences also apply through procps-2.0.10. 6a. Interface Etiquette -*- Input and output are far more carefully implemented in this top. You won't be subjected to 4 - 5 'Unknown command' messages should you press the wrong key. -*- You need suffer a confirmation message only when the results of a command are not obvious by their effects on the display. -*- The Help screen will no longer overflow, even when running with a 24 row xterm (vt100). -*- The fields selection/ordering screens do not carelessly destroy important information through unintended line wraps. -*- Should you narrow a xterm window to less than 80 columns while this top is running, you will not be left with an utterly worthless, embarrassing display. 6b. Expanded Configurable Display Support -*- In an SMP environment, you can choose between a summary dis- play or you may show each cpu separately. No longer must this choice be irrevocably made at startup. -*- There are new fields and with this top, any field is selectable for sorting. Plus, your sorted column can be instantly reversed with just a single keystroke. -*- You may optionally apply 2 distinct types of highlighting to running tasks and/or sorted columns. With this top, you'll be able to instantly spot running tasks and always know the current sort field. -*- While you could continue to use the more familiar (and boring) monochrome display, you might want to try this top's new color display. You can even create your own unique col- ors used in summaries, messages, headings and tasks, each of which can be made persistent until you choose to change them. -*- Up to four separate windows can be displayed simultaneously, giving you four separate ways to sort and view the tasks cur- rently cluttering up your system. You could have one view by pids, another by cpu usage, yet another showing memory con- sumption. You get the idea... -*- Each window comes with pre-configured (but user configurable) fields and you can size each window individually. -*- Virtually every one of this top's options (summaries, fields, colors, sorted column, etc.) is separately configurable for each of those four windows. Heck, you can even change a window's name, if you don't care for top's choices. Your changes will be reflected not only when you're in what top calls alternate-display mode but also on his special new 'Windows' help screen. -*- And, [ ** Drum-Roll + Ta-Da ** ] with just one keystroke you can quickly switch between full-screen and multiple window modes! Or, with a different keystroke, toggle a single win- dow Off for now, then On again later!! 6c. Enhanced Field/Column Management -*- Many Field/Column names have been changed to make them more intuitive, more self-descriptive. And with this top you won't be fooled with field choices that are "not yet imple- mented". -*- Task memory statistics are more meaningful and more accurate. -*- You'll finally have complete display integrity regardless of field selections, their order or screen width. And that means the command column no longer need be kept as the right- most field, lest your screen turn to <bleep> when all the following columns get misaligned. 6d. Customization Flexibility -*- You have complete program naming freedom with no internal ties to a specific personal configuration file. Symbolic links could be used to establish different configuration files reflecting the different personalities of your cus- tomized "tops", under whatever aliases you've used. Thus, you could have an alias for running top in 'Batch mode', another for when you work from the Linux console and maybe a third used with X-Windows. All of that, yet still just a single binary image! -*- All of your configuration choices can be preserved in a per- sonal configuration file, including any changes made on a per-window basis. Thus, once you personalize things they remain personalized until you decide to change them again. This top has been completely cured of: i-cant-remember-so-please-do-that-all-over-again ( and again, and again ... ) The bottom line is this: if you save your configuration before quitting top, upon restart the display will appear exactly as you left it. And that means you no longer have to keep top running until-the-end-of-time (ok, a long time anyway), lest your customizations go bye-bye.## 7. NOTES and Rantings -----------------------------------------------## 7a. The top Binary To whom it may (should) concern: this top, even with its vastly expanded capabilities, is only slightly larger than the old top. Were it not for extensive help text and additional sort callbacks, it would be smaller. Throw source carelessly at objectives, it will produce equally careless machine instructions. example: (num_pages - an_address)/1024 == duh? kicker: document result as broken, due to elf! ---------------------------------------------- I know you're out there, are you getting this? Now, as for all those new capabilities like colors and windows and highlighting, you'd expect this top to be the "mother of all pigs" compared to old top -- right? Yea, with this top expect following piglets: . A smaller virtual image and resident footprint . Slightly fewer major page faults . A large reduction in minor page faults for SMP . The same or better response time . The same or even less CPU costs Ideally any comparison of the old and new top should be against the same libproc format (32-bit or 64-bit tics) and run in a true or simulated SMP environment (producing separate CPU stats). This latter requirement will coax old top into handling his own '/proc/stat' access -- something this top always does, but with less cost. 7b. Comparing Performance Even with equivalent libraries and '/proc/stat' access, it's dif- ficult to accurately compare tops using their own displays. Results for these cpu-intensive programs (who frequently exceed their time-slice) generally show a wide disparity in %CPU. This is due to differing call patterns, kernel preemptions and the tim- ing of process snapshots. For slightly better results, start each program with the following commands: ./old-top -d 0.5 nice -n-10 ./new-top -d 0.4 While actually putting this top at a performance disadvantage, the higher scheduling priority and staggered timing will periodically yield a somewhat truer picture. You could even reverse those roles and get similar results. The most consistent performance results will be obtained 'off- line', using your shell's time pipe or the time program itself. And even in a single processor environment or without equivalent libraries, total cpu costs (user time + system time) are similar. However, this top's cpu costs ARE influenced by the capabilities you choose to exploit, even if they don't SEEM to be reflected in such timings. So let's examine some... 7c. Cost of Stuff Colors Cost -- Nada (almost). Once the terminfo strings are built (at and during a user's behest) they are SAVED with each window's stuff. And while there will be extra tty escape sequences transmitted because of colors, it makes no difference which 'char *' is actually used. Highlighting Cost -- Nada (maybe), or blame it on Rio. On second thought, let's blame it on the user. For row highlighting, there is only the cost of those extra tty escape sequences (same as for colors). For column highlight- ing, there is a fairly significant cost associated with column transition management combined with even more tty output. These increased costs are incurred on every task display row. Sooo... hey USER -- do NOT highlight COLUMNS. You shouldn't need a constant visual reminder of your chosen sort field. However, if you forget which field top is sorting it can serve as a quick visual reminder. Windows Cost -- Nada (if just 1 window). If more than 1 window, almost certainly NOT Nada so blame it on reality. Colors are not an issue, but those sort fields are. If we could trust the user to always select the same 'c' state, 'S' state and sort field (hey, why ya got multiple windows then user, huh?) AND if we can trust someone to recompile top with a #define enabled, then we could achieve 'Nada'. Ok, not likely, so we're gonna' be doing multiple sorts. BUT, it may not be as bad as it sounds. Those sorts involve point- ers only. And, that's as good as it gets ! (right Mr. N?) 7d. The top Sources top.h Unlike his predecessor, this top has a proper header file. It contains ONLY declarations, NOT definitions. And there are several conditionals present to help with further customiza- tions and experimentation. All are Off by default. top.c Hopefully proves that source code needn't be a disorganized, misaligned MESS. And, WHO says a source listing shouldn't occasionally make you SMILE? Why, top.c even does a darn good job of following the suggestions in a document hardly anybody seems to observe.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -