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

Function rufetchtd

freebsd/kern/kern_resource.c:850–875  ·  view source on GitHub ↗

Collect resource usage for a single thread. */

Source from the content-addressed store, hash-verified

848
849/* Collect resource usage for a single thread. */
850void
851rufetchtd(struct thread *td, struct rusage *ru)
852{
853 struct proc *p;
854 uint64_t runtime, u;
855
856 p = td->td_proc;
857 PROC_STATLOCK_ASSERT(p, MA_OWNED);
858 THREAD_LOCK_ASSERT(td, MA_OWNED);
859 /*
860 * If we are getting stats for the current thread, then add in the
861 * stats that this thread has accumulated in its current time slice.
862 * We reset the thread and CPU state as if we had performed a context
863 * switch right here.
864 */
865 if (td == curthread) {
866 u = cpu_ticks();
867 runtime = u - PCPU_GET(switchtime);
868 td->td_runtime += runtime;
869 td->td_incruntime += runtime;
870 PCPU_SET(switchtime, u);
871 }
872 ruxagg_locked(p, td);
873 *ru = td->td_ru;
874 calcru1(p, &td->td_rux, &ru->ru_utime, &ru->ru_stime);
875}
876
877/* XXX: the MI version is too slow to use: */
878#ifndef __HAVE_INLINE_FLSLL

Callers 2

fill_kinfo_threadFunction · 0.85
kern_getrusageFunction · 0.85

Calls 2

ruxagg_lockedFunction · 0.85
calcru1Function · 0.85

Tested by

no test coverage detected