summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-01-24 10:43:25 +0000
committerjhb <jhb@FreeBSD.org>2001-01-24 10:43:25 +0000
commit180bd8bf65584c3f98a7588b8b2c686f3c8ca554 (patch)
tree28b5785bd0308ccd8ad6a32f806ca95c236687f9 /sys
parenteef4e5d2f9f9e5cdaffeaa2f07af13e91dc79eba (diff)
downloadFreeBSD-src-180bd8bf65584c3f98a7588b8b2c686f3c8ca554.zip
FreeBSD-src-180bd8bf65584c3f98a7588b8b2c686f3c8ca554.tar.gz
- Proc locking.
- P_FOO -> PS_FOO.
Diffstat (limited to 'sys')
-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 5a8ade6..6d45911 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)
OpenPOWER on IntegriCloud