Deleted Added
full compact
kern_clock.c (209059) kern_clock.c (209371)
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_clock.c 209059 2010-06-11 18:46:34Z jhb $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_clock.c 209371 2010-06-20 21:33:29Z mav $");
39
40#include "opt_kdb.h"
41#include "opt_device_polling.h"
42#include "opt_hwpmc_hooks.h"
43#include "opt_ntp.h"
44#include "opt_watchdog.h"
45
46#include <sys/param.h>

--- 340 unchanged lines hidden (view full) ---

387 void *dummy;
388{
389 register int i;
390
391 /*
392 * Set divisors to 1 (normal case) and let the machine-specific
393 * code do its bit.
394 */
39
40#include "opt_kdb.h"
41#include "opt_device_polling.h"
42#include "opt_hwpmc_hooks.h"
43#include "opt_ntp.h"
44#include "opt_watchdog.h"
45
46#include <sys/param.h>

--- 340 unchanged lines hidden (view full) ---

387 void *dummy;
388{
389 register int i;
390
391 /*
392 * Set divisors to 1 (normal case) and let the machine-specific
393 * code do its bit.
394 */
395 mtx_init(&time_lock, "time lock", NULL, MTX_SPIN);
395 mtx_init(&time_lock, "time lock", NULL, MTX_DEF);
396 cpu_initclocks();
397
398 /*
399 * Compute profhz/stathz, and fix profhz if needed.
400 */
401 i = stathz ? stathz : hz;
402 if (profhz == 0)
403 profhz = i;

--- 40 unchanged lines hidden (view full) ---

444 if (profprocs == 0)
445 return;
446 cnt = DPCPU_PTR(prof_cnt);
447 *cnt += profhz;
448 if (*cnt >= t2hz) {
449 *cnt -= t2hz;
450 if (*cnt >= t2hz)
451 *cnt = 0;
396 cpu_initclocks();
397
398 /*
399 * Compute profhz/stathz, and fix profhz if needed.
400 */
401 i = stathz ? stathz : hz;
402 if (profhz == 0)
403 profhz = i;

--- 40 unchanged lines hidden (view full) ---

444 if (profprocs == 0)
445 return;
446 cnt = DPCPU_PTR(prof_cnt);
447 *cnt += profhz;
448 if (*cnt >= t2hz) {
449 *cnt -= t2hz;
450 if (*cnt >= t2hz)
451 *cnt = 0;
452 profclock(usermode, pc);
452 profclock(usermode, pc);
453 }
454}
455
456/*
457 * Each time the real-time timer fires, this function is called on all CPUs.
458 * Note that hardclock() calls hardclock_cpu() for the boot CPU, so only
459 * the other CPUs in the system need to call this function.
460 */

--- 133 unchanged lines hidden (view full) ---

594 register struct proc *p;
595{
596
597 PROC_LOCK_ASSERT(p, MA_OWNED);
598 if (p->p_flag & P_STOPPROF)
599 return;
600 if ((p->p_flag & P_PROFIL) == 0) {
601 p->p_flag |= P_PROFIL;
453 }
454}
455
456/*
457 * Each time the real-time timer fires, this function is called on all CPUs.
458 * Note that hardclock() calls hardclock_cpu() for the boot CPU, so only
459 * the other CPUs in the system need to call this function.
460 */

--- 133 unchanged lines hidden (view full) ---

594 register struct proc *p;
595{
596
597 PROC_LOCK_ASSERT(p, MA_OWNED);
598 if (p->p_flag & P_STOPPROF)
599 return;
600 if ((p->p_flag & P_PROFIL) == 0) {
601 p->p_flag |= P_PROFIL;
602 mtx_lock_spin(&time_lock);
602 mtx_lock(&time_lock);
603 if (++profprocs == 1)
604 cpu_startprofclock();
603 if (++profprocs == 1)
604 cpu_startprofclock();
605 mtx_unlock_spin(&time_lock);
605 mtx_unlock(&time_lock);
606 }
607}
608
609/*
610 * Stop profiling on a process.
611 */
612void
613stopprofclock(p)

--- 7 unchanged lines hidden (view full) ---

621 while (p->p_profthreads != 0)
622 msleep(&p->p_profthreads, &p->p_mtx, PPAUSE,
623 "stopprof", 0);
624 p->p_flag &= ~P_STOPPROF;
625 }
626 if ((p->p_flag & P_PROFIL) == 0)
627 return;
628 p->p_flag &= ~P_PROFIL;
606 }
607}
608
609/*
610 * Stop profiling on a process.
611 */
612void
613stopprofclock(p)

--- 7 unchanged lines hidden (view full) ---

621 while (p->p_profthreads != 0)
622 msleep(&p->p_profthreads, &p->p_mtx, PPAUSE,
623 "stopprof", 0);
624 p->p_flag &= ~P_STOPPROF;
625 }
626 if ((p->p_flag & P_PROFIL) == 0)
627 return;
628 p->p_flag &= ~P_PROFIL;
629 mtx_lock_spin(&time_lock);
629 mtx_lock(&time_lock);
630 if (--profprocs == 0)
631 cpu_stopprofclock();
630 if (--profprocs == 0)
631 cpu_stopprofclock();
632 mtx_unlock_spin(&time_lock);
632 mtx_unlock(&time_lock);
633 }
634}
635
636/*
637 * Statistics clock. Updates rusage information and calls the scheduler
638 * to adjust priorities of the active thread.
639 *
640 * This should be called by all active processors.

--- 179 unchanged lines hidden ---
633 }
634}
635
636/*
637 * Statistics clock. Updates rusage information and calls the scheduler
638 * to adjust priorities of the active thread.
639 *
640 * This should be called by all active processors.

--- 179 unchanged lines hidden ---