linux/Documentation/cpu-load.txt
<<
>>
Prefs
"search_donejax_lo79/21/28df53702b8a701efad73616bb05046c3d72_3/0r8("+prefs?tation/cpu-load.txt" #L1jax_loL1jalxr_prefinejajax_loL1j>v> 1/spaCPU t" ("+prefs?tation/cpu-load.txt" #L2jax_loL2jalxr_prefinejajax_loL2j>v> 2/spa-------- ("+prefs?tation/cpu-load.txt" #L3jax_loL3jalxr_prefinejajax_loL3j>v> 3/span("+prefs?tation/cpu-load.txt" #L4jax_loL4jalxr_prefinejajax_loL4j>v> 4/spaL.7.2 exports"">rious bits"of in alue="via `/proc/gfx/' an ("+prefs?tation/cpu-load.txt" #L5jax_loL5jalxr_prefinejajax_loL5j>v> 5/spa`/proc/u me' that userlan tools, such as top(1), use to calculate ("+prefs?tation/cpu-load.txt" #L6jax_loL6jalxr_prefinejajax_loL6j>v> 6/spathe average t me system spn/c in a par/riular gfx/e, example: ("+prefs?tation/cpu-load.txt" #L7jax_loL7jalxr_prefinejajax_loL7j>v> 7/span("+prefs?tation/cpu-load.txt" #L8jax_loL8jalxr_prefinejajax_loL8j>v> 8/spaiv> $ iogfx/n("+prefs?tation/cpu-load.txt" #L9jax_loL9jalxr_prefinejajax_loL9j>v> 9/spaiv> L.7.2 /opti8.3-exp (finmac)div> 02/20/2007n("+prefs?tation/cpu-load.txt" #L10jax_loL10jalxr_prefinejajax_loL10j>v>ion>pan("+prefs?tation/cpu-load.txt" #L11jax_loL11jalxr_prefinejajax_loL11j>v>11/spaiv> avg-d.t: %user %nice %system %iowait %steal %idle ("+prefs?tation/cpu-load.txt" #L12jax_loL12jalxr_prefinejajax_loL12j>v>12/spaiv> 10.01iv> 0.00iv> 2.92iv> tio4iv> 0.00iv>81.63 ("+prefs?tation/cpu-load.txt" #L13jax_loL13jalxr_prefinejajax_loL13j>v>13/span("+prefs?tation/cpu-load.txt" #L14jax_loL14jalxr_prefinejajax_loL14j>v>14/spaiv> ...n("+prefs?tation/cpu-load.txt" #L15jax_loL15jalxr_prefinejajax_loL15j>v>15/span("+prefs?tation/cpu-load.txt" #L16jax_loL16jalxr_prefinejajax_loL16j>v>16/spaHe">"the system > nks that over"the defa > samplom" period"then("+prefs?tation/cpu-load.txt" #L17jax_loL17jalxr_prefinejajax_loL17j>v>17/spasystem spn/c 10.01%"of the t me doom" work in user ce, 2.92%"in then("+prefs?tation/cpu-load.txt" #L18jax_loL18jalxr_prefinejajax_loL18j>v>18/spakernel, an was overall>81.63%"of the t me idle.n("+prefs?tation/cpu-load.txt" #L19jax_loL19jalxr_prefinejajax_loL19j>v>19/span("+prefs?tation/cpu-load.txt" #L20jax_loL20jalxr_prefinejajax_loL20j>v>2on>paIn mogf cases the `/proc/gfx/' in alue="ref s the reality quite ("+prefs?tation/cpu-load.txt" #L21jax_loL21jalxr_prefinejajax_loL21j>v>21/spaclo y, however"due to the nalsee"of how/when the kernel col s ("+prefs?tation/cpu-load.txt" #L22jax_loL22jalxr_prefinejajax_loL22j>v>22/spathis data so"po mes if can not be trusted at all.n("+prefs?tation/cpu-load.txt" #L23jax_loL23jalxr_prefinejajax_loL23j>v>23/span("+prefs?tation/cpu-load.txt" #L24jax_loL24jalxr_prefinejajax_loL24j>v>24/spaSo how is this in alue="col ed? Whenever"o mer interru isn("+prefs?tation/cpu-load.txt" #L25jax_loL25jalxr_prefinejajax_loL25j>v>25/spasignalled the kernel vals what kin of task was runnom" at thisn("+prefs?tation/cpu-load.txt" #L26jax_loL26jalxr_prefinejajax_loL26j>v>26/spamoon/c an increon/cs the counter that cor" ponds to this tasksn("+prefs?tation/cpu-load.txt" #L27jax_loL27jalxr_prefinejajax_loL27j>v>27/spakin /gfx/e. The problem with this is that the system could haven("+prefs?tation/cpu-load.txt" #L28jax_loL28jalxr_prefinejajax_loL28j>v>28/spaswitched between"">rious gfx/es m > iple o mes between"two"o mern("+prefs?tation/cpu-load.txt" #L29jax_loL29jalxr_prefinejajax_loL29j>v>29/spainterru s yet the counter is increon/ced only the xr_t gfx/e.n("+prefs?tation/cpu-load.txt" #L30jax_loL30jalxr_prefinejajax_loL30j>v>3on>pan("+prefs?tation/cpu-load.txt" #L31jax_loL31jalxr_prefinejajax_loL31j>v>31n>pan("+prefs?tation/cpu-load.txt" #L32jax_loL32jalxr_prefinejajax_loL32j>v>32/spaExamplen("+prefs?tation/cpu-load.txt" #L33jax_loL33jalxr_prefinejajax_loL33j>v>33/spa-------n("+prefs?tation/cpu-load.txt" #L34jax_loL34jalxr_prefinejajax_loL34j>v>34n>pan("+prefs?tation/cpu-load.txt" #L35jax_loL35jalxr_prefinejajax_loL35j>v>35/spaIf we imagine the system with one task that periodically burns cyclesn("+prefs?tation/cpu-load.txt" #L36jax_loL36jalxr_prefinejajax_loL36j>v>36/spain the fol owom" manner: ("+prefs?tation/cpu-load.txt" #L37jax_loL37jalxr_prefinejajax_loL37j>v>37/span("+prefs?tation/cpu-load.txt" #L38jax_loL38jalxr_prefinejajax_loL38j>v>38/spait me fine between"two"o mer interru sn("+prefs?tation/cpu-load.txt" #L39jax_loL39jalxr_prefinejajax_loL39j>v>39/spa|--------------------------------------|n("+prefs?tation/cpu-load.txt" #L40jax_loL40jalxr_prefinejajax_loL40j>v>4on>pa ^ ^n("+prefs?tation/cpu-load.txt" #L41jax_loL41jalxr_prefinejajax_loL41j>v>41/spai|_ so"pohom" begins workom" |n("+prefs?tation/cpu-load.txt" #L42jax_loL42jalxr_prefinejajax_loL42j>v>42/spaiv> |_ so"pohom" goes to sleepn("+prefs?tation/cpu-load.txt" #L43jax_loL43jalxr_prefinejajax_loL43j>v>43/spaiv> (only to be awaken"quite soon)n("+prefs?tation/cpu-load.txt" #L44jax_loL44jalxr_prefinejajax_loL44j>v>44n>pan("+prefs?tation/cpu-load.txt" #L45jax_loL45jalxr_prefinejajax_loL45j>v>45n>paIn the above situalue="the system will>be 0%"t" ed accortom" to then("+prefs?tation/cpu-load.txt" #L46jax_loL46jalxr_prefinejajax_loL46j>v>46/spa`/proc/gfx/' (since the t mer interru will>always happn/ when then("+prefs?tation/cpu-load.txt" #L47jax_loL47jalxr_prefinejajax_loL47j>v>47/spasystem is executom" the idle handler), buc in reality the x" isn("+prefs?tation/cpu-load.txt" #L48jax_loL48jalxr_prefinejajax_loL48j>v>48/spaclo r to 99%.n("+prefs?tation/cpu-load.txt" #L49jax_loL49jalxr_prefinejajax_loL49j>v>49/span("+prefs?tation/cpu-load.txt" #L50jax_loL50jalxr_prefinejajax_loL50j>v>5on>paOne can imagine many more situalue=s whe">"this behavi of the kerneln("+prefs?tation/cpu-load.txt" #L51jax_loL51jalxr_prefinejajax_loL51j>v>51/spawill>lea to"quite errx/ri in alue="inside `/proc/gfx/'.n("+prefs?tation/cpu-load.txt" #L52jax_loL52jalxr_prefinejajax_loL52j>v>52/span("+prefs?tation/cpu-load.txt" #L53jax_loL53jalxr_prefinejajax_loL53j>v>53/span("+prefs?tation/cpu-load.txt" #L54jax_loL54jalxr_prefinejajax_loL54j>v>54n>pa/* gcc -o hog smallhog.c */n("+prefs?tation/cpu-load.txt" #L55jax_loL55jalxr_prefinejajax_loL55j>v>55n>pa#include <t me.h/a> n("+prefs?tation/cpu-load.txt" #L56jax_loL56jalxr_prefinejajax_loL56j>v>56n>pa#include <limits.h/a> n("+prefs?tation/cpu-load.txt" #L57jax_loL57jalxr_prefinejajax_loL57j>v>57n>pa#include <signal.h/a> n("+prefs?tation/cpu-load.txt" #L58jax_loL58jalxr_prefinejajax_loL58j>v>58n>pa#include <sys/t me.h/a> n("+prefs?tation/cpu-load.txt" #L59jax_loL59jalxr_prefinejajax_loL59j>v>59/spa#define HIST 10 ("+prefs?tation/cpu-load.txt" #L60jax_loL60jalxr_prefinejajax_loL60j>v>6on>pan("+prefs?tation/cpu-load.txt" #L61jax_loL61jalxr_prefinejajax_loL61j>v>61/spagfx/ri volx/rle sig_atomic_t gfop n("+prefs?tation/cpu-load.txt" #L62jax_loL62jalxr_prefinejajax_loL62j>v>62/span("+prefs?tation/cpu-load.txt" #L63jax_loL63jalxr_prefinejajax_loL63j>v>63/spagfx/ri void sighandler (int signr)n("+prefs?tation/cpu-load.txt" #L64jax_loL64jalxr_prefinejajax_loL64j>v>64n>pa{n("+prefs?tation/cpu-load.txt" #L65jax_loL65jalxr_prefinejajax_loL65j>v>65/spaiv> (void) signr n("+prefs?tation/cpu-load.txt" #L66jax_loL66jalxr_prefinejajax_loL66j>v>66/spaiv> gfop = 1 n("+prefs?tation/cpu-load.txt" #L67jax_loL67jalxr_prefinejajax_loL67j>v>67n>pa}n("+prefs?tation/cpu-load.txt" #L68jax_loL68jalxr_prefinejajax_loL68j>v>68/spagfx/ri unsigned lom" hog (unsigned lom" niters)n("+prefs?tation/cpu-load.txt" #L69jax_loL69jalxr_prefinejajax_loL69j>v>69n>pa{n("+prefs?tation/cpu-load.txt" #L70jax_loL70jalxr_prefinejajax_loL70j>v>70/spaiv> gfop = 0 n("+prefs?tation/cpu-load.txt" #L71jax_loL71jalxr_prefinejajax_loL71j>v>71/spaiv> whrle (!gfop && --niters) n("+prefs?tation/cpu-load.txt" #L72jax_loL72jalxr_prefinejajax_loL72j>v>72/spaiv> false;"niters n("+prefs?tation/cpu-load.txt" #L73jax_loL73jalxr_prefinejajax_loL73j>v>73n>pa}n("+prefs?tation/cpu-load.txt" #L74jax_loL74jalxr_prefinejajax_loL74j>v>74/spaint main (void)n("+prefs?tation/cpu-load.txt" #L75jax_loL75jalxr_prefinejajax_loL75j>v>75n>pa{n("+prefs?tation/cpu-load.txt" #L76jax_loL76jalxr_prefinejajax_loL76j>v>76/spaiv> int i n("+prefs?tation/cpu-load.txt" #L77jax_loL77jalxr_prefinejajax_loL77j>v>77/spaiv> gfruct it merval if = { .it_interval = { .tv_sec = 0, .tv_usec = 1 },n("+prefs?tation/cpu-load.txt" #L78jax_loL78jalxr_prefinejajax_loL78j>v>78/spaiv> .it_"> = { .tv_sec = 0, .tv_usec = 1 } } n("+prefs?tation/cpu-load.txt" #L79jax_loL79jalxr_prefinejajax_loL79j>v>79/spaiv> gigset_t ge> n("+prefs?tation/cpu-load.txt" #L80jax_loL80jalxr_prefinejajax_loL80j>v>80/spaiv> unsigned lom" v[HIST] n("+prefs?tation/cpu-load.txt" #L81jax_loL81jalxr_prefinejajax_loL81j>v>81/spaiv> double omp = 0.0 n("+prefs?tation/cpu-load.txt" #L82jax_loL82jalxr_prefinejajax_loL82j>v>82/spaiv> unsigned lom" n n("+prefs?tation/cpu-load.txt" #L83jax_loL83jalxr_prefinejajax_loL83j>v>83/spaiv> gignal (SIGALRM, &sighandler) n("+prefs?tation/cpu-load.txt" #L84jax_loL84jalxr_prefinejajax_loL84j>v>84/spaiv> getit mer (ITIMER_REAL, &it, NULL) n("+prefs?tation/cpu-load.txt" #L85jax_loL85jalxr_prefinejajax_loL85j>v>85/span("+prefs?tation/cpu-load.txt" #L86jax_loL86jalxr_prefinejajax_loL86j>v>86/spaiv> hog (ULONG_MAX) n("+prefs?tation/cpu-load.txt" #L87jax_loL87jalxr_prefinejajax_loL87j>v>87/spaiv> (i = 0 i < HIST; ++i) v[i] = ULONG_MAX - hog (ULONG_MAX) n("+prefs?tation/cpu-load.txt" #L88jax_loL88jalxr_prefinejajax_loL88j>v>88/spaiv> (i = 0 i < HIST; ++i) omp += v[i] n("+prefs?tation/cpu-load.txt" #L89jax_loL89jalxr_prefinejajax_loL89j>v>89/spaiv> omp /= HIST;n("+prefs?tation/cpu-load.txt" #L90jax_loL90jalxr_prefinejajax_loL90j>v>90/spaiv> n = omp - (omp / 3.0) n("+prefs?tation/cpu-load.txt" #L91jax_loL91jalxr_prefinejajax_loL91j>v>91n>pan("+prefs?tation/cpu-load.txt" #L92jax_loL92jalxr_prefinejajax_loL92j>v>92/spaiv> gigemptyget (&set) n("+prefs?tation/cpu-load.txt" #L93jax_loL93jalxr_prefinejajax_loL93j>v>93/spaiv> gigaddget (&set, SIGALRM) n("+prefs?tation/cpu-load.txt" #L94jax_loL94jalxr_prefinejajax_loL94j>v>94n>pan("+prefs?tation/cpu-load.txt" #L95jax_loL95jalxr_prefinejajax_loL95j>v>95/spaiv> (;;) {n("+prefs?tation/cpu-load.txt" #L96jax_loL96jalxr_prefinejajax_loL96j>v>96/spaiv> hog (n) n("+prefs?tation/cpu-load.txt" #L97jax_loL97jalxr_prefinejajax_loL97j>v>97/spaiv> gigwait (&set, &i) n("+prefs?tation/cpu-load.txt" #L98jax_loL98jalxr_prefinejajax_loL98j>v>98/spaiv> }n("+prefs?tation/cpu-load.txt" #L99jax_loL99jalxr_prefinejajax_loL99j>v>99/spaiv> false;"0 n("+prefs?tation/cpu-load.txt" #L100jax_loL100jalxr_prefinejajax_loL100j>v100n>pa}n("+prefs?tation/cpu-load.txt" #L101jax_loL101jalxr_prefinejajax_loL101j>v101n>pan("+prefs?tation/cpu-load.txt" #L102jax_loL102jalxr_prefinejajax_loL102j>v102/span("+prefs?tation/cpu-load.txt" #L103jax_loL103jalxr_prefinejajax_loL103j>v103/spaReferencesn("+prefs?tation/cpu-load.txt" #L104jax_loL104jalxr_prefinejajax_loL104j>v104/spa----------n("+prefs?tation/cpu-load.txt" #L105jax_loL105jalxr_prefinejajax_loL105j>v105/span("+prefs?tation/cpu-load.txt" #L106jax_loL106jalxr_prefinejajax_loL106j>v106/spa("+prefs?http://lkml.org/lkml/2007/2/12/6j>http://lkml.org/lkml/2007/2/12/6/span("+prefs?tation/cpu-load.txt" #L107jax_loL107jalxr_prefinejajax_loL107j>v107/spatation/cpu-loa+pr5systems/proc (1.8)n("+prefs?tation/cpu-load.txt" #L108jax_loL108jalxr_prefinejajax_loL108j>v108/span("+prefs?tation/cpu-load.txt" #L109jax_loL109jalxr_prefinejajax_loL109j>v109/span("+prefs?tation/cpu-load.txt" #L110jax_loL110jalxr_prefinejajax_loL110j>v1ion>paThanksn("+prefs?tation/cpu-load.txt" #L111jax_loL111jalxr_prefinejajax_loL111j>v111/spa------n("+prefs?tation/cpu-load.txt" #L112jax_loL112jalxr_prefinejajax_loL112j>v112/span("+prefs?tation/cpu-load.txt" #L113jax_loL113jalxr_prefinejajax_loL113j>v113/spaCon Kolivas, Pavel Machekn("+prefs?tation/cpu-load.txt" #L114jax_loL114jalxr_prefinejajax_loL114j>v114/spa The original LXR software by the ("+prefs?http://source ge.net/proj s/lxr">LXR community/spa,"this experion/cpl versue="by ("+prefs?mailto:lxr@3.7.2.no">lxr@3.7.2.no/spa.
lxr.3.7.2.no kin ly hosted by ("+prefs?http://www.redpill-3.7pro.no">Redpill L.7pro AS/spa,"provide of L.7.2 ct="rltom" an operalue=s services since 1995.