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

Function get_cputime

freebsd/kern/kern_time.c:287–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287static int
288get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats)
289{
290 struct proc *p, *p2;
291 struct thread *td2;
292 lwpid_t tid;
293 pid_t pid;
294 int error;
295
296 p = td->td_proc;
297 if ((clock_id & CPUCLOCK_PROCESS_BIT) == 0) {
298 tid = clock_id & CPUCLOCK_ID_MASK;
299 td2 = tdfind(tid, p->p_pid);
300 if (td2 == NULL)
301 return (EINVAL);
302 kern_thread_cputime(td2, ats);
303 PROC_UNLOCK(td2->td_proc);
304 } else {
305 pid = clock_id & CPUCLOCK_ID_MASK;
306 error = pget(pid, PGET_CANSEE, &p2);
307 if (error != 0)
308 return (EINVAL);
309 kern_process_cputime(p2, ats);
310 PROC_UNLOCK(p2);
311 }
312 return (0);
313}
314
315int
316kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats)

Callers 1

kern_clock_gettimeFunction · 0.85

Calls 4

tdfindFunction · 0.85
kern_thread_cputimeFunction · 0.85
kern_process_cputimeFunction · 0.85
pgetFunction · 0.70

Tested by

no test coverage detected