aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_clock.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-01-24 10:43:25 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-01-24 10:43:25 +0000
commit01cd094c32397dcdce109b84d487e544a036824c (patch)
tree36eda8c92de484f8a713701439a3df2ae4e242a7 /sys/kern/kern_clock.c
parentf202965e954e3aa4c24715722b18965c71cc7641 (diff)
downloadsrc-01cd094c32397dcdce109b84d487e544a036824c.tar.gz
src-01cd094c32397dcdce109b84d487e544a036824c.zip
Notes
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r--sys/kern/kern_clock.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 5a8ade61cfd9..6d45911d9dd8 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -170,13 +170,17 @@ hardclock(frame)
if (CLKF_USERMODE(frame) &&
timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- p->p_flag |= P_ALRMPEND;
+ mtx_enter(&sched_lock, MTX_SPIN);
+ p->p_sflag |= PS_ALRMPEND;
aston();
+ mtx_exit(&sched_lock, MTX_SPIN);
}
if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- p->p_flag |= P_PROFPEND;
+ mtx_enter(&sched_lock, MTX_SPIN);
+ p->p_sflag |= PS_PROFPEND;
aston();
+ mtx_exit(&sched_lock, MTX_SPIN);
}
}
@@ -283,8 +287,14 @@ startprofclock(p)
{
int s;
- if ((p->p_flag & P_PROFIL) == 0) {
- p->p_flag |= P_PROFIL;
+ /*
+ * XXX; Right now sched_lock protects statclock(), but perhaps
+ * it should be protected later on by a time_lock, which would
+ * cover psdiv, etc. as well.
+ */
+ mtx_enter(&sched_lock, MTX_SPIN);
+ if ((p->p_sflag & PS_PROFIL) == 0) {
+ p->p_sflag |= PS_PROFIL;
if (++profprocs == 1 && stathz != 0) {
s = splstatclock();
psdiv = pscnt = psratio;
@@ -292,6 +302,7 @@ startprofclock(p)
splx(s);
}
}
+ mtx_exit(&sched_lock, MTX_SPIN);
}
/*
@@ -303,8 +314,9 @@ stopprofclock(p)
{
int s;
- if (p->p_flag & P_PROFIL) {
- p->p_flag &= ~P_PROFIL;
+ mtx_enter(&sched_lock, MTX_SPIN);
+ if (p->p_sflag & PS_PROFIL) {
+ p->p_sflag &= ~PS_PROFIL;
if (--profprocs == 0 && stathz != 0) {
s = splstatclock();
psdiv = pscnt = 1;
@@ -312,6 +324,7 @@ stopprofclock(p)
splx(s);
}
}
+ mtx_exit(&sched_lock, MTX_SPIN);
}
/*
@@ -342,7 +355,7 @@ statclock(frame)
* If this process is being profiled, record the tick.
*/
p = curproc;
- if (p->p_flag & P_PROFIL)
+ if (p->p_sflag & PS_PROFIL)
addupc_intr(p, CLKF_PC(frame), 1);
#if defined(SMP) && defined(BETTER_CLOCK)
if (stathz != 0)