/proc/stat [Subject changed]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear List,

I have looked through all the archives, and have unfortunately not been able to
find any answers to my questions regarding using the /proc filesystem.

I would greatly appreciate it if anyone in the know, could spare the two minutes to have a look at my question below, or tell me where I should look to get it
answered.

Thanks in advance for your help,

Andrew


On Dec 2, 2005, at 4:17 PM, Andrew Miehs wrote:

Dear list,

I had some questions regarding using /proc/stat (on the 2.6 kernel).

Can I assume that reading /proc/stat is 'atomic'? Can I assume that when I read
the file, that nothing will change the data while I am reading it?
IE:
  cpu  15948315 4687107 3321012 122412279 659908 43304 144288
  cpu0 15948315 4687107 3321012 122412279 659908 43304 144288

can I assume that while I am reading the third value (system), that the fourth value (idle) will not be changed underneath me? Can I assume that all the lines? cpu, cpu0 will all be
generated at once?


My second question is regarding using these values to calculate usage...

Should I calculate usage by
(where T1, T2 are time)

A) read /proc/stat
Fill variables UserT1, NiceT1, SystemT1, IdleT1, IOWaitT1, irqT1, irq2T1
   wait a time
Fill variables UserT2, NiceT2, SystemT2, IdleT2, IOWaitT2, irqT2, irq2T2 DeltaTotalTime=(UserT2-UserT1)+(NiceT2-NiceT1)+(SystemT2- SystemT1)+(.........)

Then calculate the values I want as the delta variableOfInterest / total delta
   ie: (UserT2-UserT1)/DeltaTotalTime

Can I assume that all these values added together should add up to 100%?


or


B) read /proc/stat
read variable of interest, ie: UserT1 and btimeT1 and number of CPUs
   wait a time
read variable of interest, ie: UserT2 and btimeT2 and number of CPUs

   Then calculate the values I want as
     ((UserT2-UserT1)/NumCPU)/(btimeT2-btimeT1)*100 (Jiffies)


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux