Deleted Added
full compact
kern_synch.c (31352) kern_synch.c (31403)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 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.

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

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
1/*-
2 * Copyright (c) 1982, 1986, 1990, 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.

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

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
39 * $Id: kern_synch.c,v 1.40 1997/11/21 11:36:56 bde Exp $
39 * $Id: kern_synch.c,v 1.41 1997/11/22 08:35:38 bde Exp $
40 */
41
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/proc.h>
47#include <sys/kernel.h>

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

93
94SYSCTL_PROC(_kern, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW,
95 0, sizeof quantum, sysctl_kern_quantum, "I", "");
96
97/*
98 * Force switch among equal priority processes every 100ms.
99 */
100/* ARGSUSED */
40 */
41
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/proc.h>
47#include <sys/kernel.h>

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

93
94SYSCTL_PROC(_kern, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW,
95 0, sizeof quantum, sysctl_kern_quantum, "I", "");
96
97/*
98 * Force switch among equal priority processes every 100ms.
99 */
100/* ARGSUSED */
101void
101static void
102roundrobin(arg)
103 void *arg;
104{
105
106 need_resched();
107 timeout(roundrobin, NULL, hz / quantum);
108}
109

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

191 * (more general) method of calculating the %age of CPU used by a process.
192 */
193#define CCPU_SHIFT 11
194
195/*
196 * Recompute process priorities, every hz ticks.
197 */
198/* ARGSUSED */
102roundrobin(arg)
103 void *arg;
104{
105
106 need_resched();
107 timeout(roundrobin, NULL, hz / quantum);
108}
109

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

191 * (more general) method of calculating the %age of CPU used by a process.
192 */
193#define CCPU_SHIFT 11
194
195/*
196 * Recompute process priorities, every hz ticks.
197 */
198/* ARGSUSED */
199void
199static void
200schedcpu(arg)
201 void *arg;
202{
203 register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]);
204 register struct proc *p;
205 register int s;
206 register unsigned int newcpu;
207

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

710 newpriority = min(newpriority, MAXPRI);
711 p->p_usrpri = newpriority;
712 if (newpriority < curpriority)
713 need_resched();
714 } else {
715 need_resched();
716 }
717}
200schedcpu(arg)
201 void *arg;
202{
203 register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]);
204 register struct proc *p;
205 register int s;
206 register unsigned int newcpu;
207

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

710 newpriority = min(newpriority, MAXPRI);
711 p->p_usrpri = newpriority;
712 if (newpriority < curpriority)
713 need_resched();
714 } else {
715 need_resched();
716 }
717}
718
719/* ARGSUSED */
720static void sched_setup __P((void *dummy));
721static void
722sched_setup(dummy)
723 void *dummy;
724{
725 /* Kick off timeout driven events by calling first time. */
726 roundrobin(NULL);
727 schedcpu(NULL);
728}
729SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL)
730