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

Function kern_getitimer

freebsd/kern/kern_time.c:753–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751}
752
753int
754kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv)
755{
756 struct proc *p = td->td_proc;
757 struct timeval ctv;
758
759 if (which > ITIMER_PROF)
760 return (EINVAL);
761
762 if (which == ITIMER_REAL) {
763 /*
764 * Convert from absolute to relative time in .it_value
765 * part of real time timer. If time for real time timer
766 * has passed return 0, else return difference between
767 * current time and time for the timer to go off.
768 */
769 PROC_LOCK(p);
770 *aitv = p->p_realtimer;
771 PROC_UNLOCK(p);
772 if (timevalisset(&aitv->it_value)) {
773 microuptime(&ctv);
774 if (timevalcmp(&aitv->it_value, &ctv, <))
775 timevalclear(&aitv->it_value);
776 else
777 timevalsub(&aitv->it_value, &ctv);
778 }
779 } else {
780 PROC_ITIMLOCK(p);
781 *aitv = p->p_stats->p_timer[which];
782 PROC_ITIMUNLOCK(p);
783 }
784#ifdef KTRACE
785 if (KTRPOINT(td, KTR_STRUCT))
786 ktritimerval(aitv);
787#endif
788 return (0);
789}
790
791#ifndef _SYS_SYSPROTO_H_
792struct setitimer_args {

Callers 2

sys_getitimerFunction · 0.85
kern_setitimerFunction · 0.85

Calls 2

microuptimeFunction · 0.85
timevalsubFunction · 0.70

Tested by

no test coverage detected