Re: times()

Glynn Clements <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
João Fernandes Simplício wrote:

> I've been testing the times() function and I can't understand in what
> way is the ticking being incremented for system time measurement
> (tms_stime). I understand that tms_utime gives the ticking related to
> the process and what does tms_stime gives?

tms_utime is the amount of CPU time spent executing user-space code
(i.e. the executable and shared libraries), while tms_stime is the
amount of CPU time spent in the kernel.

> E.g.:
> 
> In 5 minutes the process gives 10000 ticks, so if the OS supports a
> maximum of 32758 process identifiers this gives us a 30% of load.
> 
> Is my thinking right or am I missing something else?

The number of PIDs doesn't come into it.

times() reports the CPU time used by a single process.

If sysconf(_SC_CLK_TCK) is 100, then 5 minutes is 5*60*100 = 30000
ticks, so 10000 ticks corresponds to 33% of the CPU time being used by
that process.

Also, note that 100% correponds to full utilisation of a single CPU. 
If you have multiple CPUs (a single CPU chip with multiple cores is
treated as multiple CPUs), a multi-threaded process can exceed 100%
CPU.

-- 
Glynn Clements <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.