MCPcopy Create free account
hub / github.com/F-Stack/f-stack / calcru

Function calcru

freebsd/kern/kern_resource.c:818–847  ·  view source on GitHub ↗

* Transform the running time and tick information in proc p into user * and system time usage. If appropriate, include the current time slice * on this CPU. */

Source from the content-addressed store, hash-verified

816 * on this CPU.
817 */
818void
819calcru(struct proc *p, struct timeval *up, struct timeval *sp)
820{
821 struct thread *td;
822 uint64_t runtime, u;
823
824 PROC_LOCK_ASSERT(p, MA_OWNED);
825 PROC_STATLOCK_ASSERT(p, MA_OWNED);
826 /*
827 * If we are getting stats for the current process, then add in the
828 * stats that this thread has accumulated in its current time slice.
829 * We reset the thread and CPU state as if we had performed a context
830 * switch right here.
831 */
832 td = curthread;
833 if (td->td_proc == p) {
834 u = cpu_ticks();
835 runtime = u - PCPU_GET(switchtime);
836 td->td_runtime += runtime;
837 td->td_incruntime += runtime;
838 PCPU_SET(switchtime, u);
839 }
840 /* Make sure the per-thread stats are current. */
841 FOREACH_THREAD_IN_PROC(p, td) {
842 if (td->td_incruntime == 0)
843 continue;
844 ruxagg(p, td);
845 }
846 calcru1(p, &p->p_rux, up, sp);
847}
848
849/* Collect resource usage for a single thread. */
850void

Callers 4

fill_kinfo_proc_onlyFunction · 0.85
kern_clock_gettimeFunction · 0.85
proc_to_reapFunction · 0.85
rufetchcalcFunction · 0.85

Calls 2

ruxaggFunction · 0.85
calcru1Function · 0.85

Tested by

no test coverage detected