Problem
The value of clock ticks (_SC_CLK_TCK) is hard coded and might varies across kernel versions and hardware platforms, it would probably be best if you could read this value dynamically.
There is an assumption here for certain conditions that might not be respected between different deployments and versions.
please read the wiki article about Kernel Timer Systems:
The original kernel timer system (called the "timer wheel) was based on incrementing a kernel-internal value (jiffies) every timer interrupt. The timer interrupt becomes the default scheduling quantum, and all other timers are based on jiffies. The timer interrupt rate (and jiffy increment rate) is defined by a compile-time constant called HZ. Different platforms use different values for HZ. Historically, the kernel used 100 as the value for HZ, yielding a jiffy interval of 10 ms. With 2.4, the HZ value for i386 was changed to 1000, yielding a jiffy interval of 1 ms. Recently (2.6.13) the kernel changed HZ for i386 to 250. (1000 was deemed too high).
Proposed solution
Make a sys call to retrieve the actual _SC_CLK_TCK and use it for process time calculations, the same has been done for Darwin:
|
// getClockTicks returns the number of click ticks in one jiffie. |
|
func getClockTicks() int { |
|
return int(C.sysconf(C._SC_CLK_TCK)) |
|
} |
Problem
The value of clock ticks (
_SC_CLK_TCK) is hard coded and might varies across kernel versions and hardware platforms, it would probably be best if you could read this value dynamically.go-sysinfo/providers/linux/process_linux.go
Line 33 in bd131ab
There is an assumption here for certain conditions that might not be respected between different deployments and versions.
please read the wiki article about Kernel Timer Systems:
Proposed solution
Make a sys call to retrieve the actual
_SC_CLK_TCKand use it for process time calculations, the same has been done for Darwin:go-sysinfo/providers/darwin/syscall_darwin.go
Lines 191 to 194 in f2015f1