- /*
- * If the cpu is currently scheduled to a process, then
- * charge it with resource utilization for a tick, updating
- * statistics which run in (user+system) virtual time,
- * such as the cpu time limit and profiling timers.
- * This assumes that the current process has been running
- * the entire last tick.
- */
- if (!is_thread_idle(thread)) {
- if (p->p_limit &&
- p->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
- time_value_t sys_time, user_time;
-
- thread_read_times(thread, &user_time, &sys_time);
- if ((sys_time.seconds + user_time.seconds + 1) >
- p->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur) {
- extern void psignal_xcpu(struct proc *);
-
- /* does psignal(p, SIGXCPU) in a thread context */
- thread_call_func(psignal_xcpu, p, FALSE);
-
- if (p->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur <
- p->p_limit->pl_rlimit[RLIMIT_CPU].rlim_max)
- p->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur += 5;
- }
- }
- if (timerisset(&p->p_stats->p_timer[ITIMER_PROF].it_value) &&
- !itimerdecr(&p->p_stats->p_timer[ITIMER_PROF], nusecs)) {
- extern void psignal_sigprof(struct proc *);
-
- /* does psignal(p, SIGPROF) in a thread context */
- thread_call_func(psignal_sigprof, p, FALSE);
- }
- }
- }