Hello t...@!
here's a diff for sys/sched.h which main purpose is to eliminate
128 magic number in SCHED_PPQ macro
-#define SCHED_PPQ (128 / SCHED_NQS) /* priorities per queue
*/
+#define SCHED_PPQ ((MAXPRI + 1) / SCHED_NQS) /* priorities per queue */
also the function definitions and structure declarations
are indented as in other new kernel code, no functional change at all
diff follows:
Index: sched.h
===================================================================
RCS file: /cvs/src/sys/sys/sched.h,v
retrieving revision 1.22
diff -N -u -p sched.h
--- sched.h 14 Apr 2009 09:13:25 -0000 1.22
+++ sched.h 29 Jul 2009 10:30:52 -0000
@@ -70,6 +70,7 @@
#define _SYS_SCHED_H_
#include <sys/queue.h>
+#include <sys/param.h>
/*
* Posix defines a <sched.h> which may want to include <sys/sched.h>
@@ -87,31 +88,31 @@
#define CP_IDLE 4
#define CPUSTATES 5
-#define SCHED_NQS 32 /* 32 run queues. */
+#define SCHED_NQS 32 /* 32 run queues. */
/*
* Per-CPU scheduler state.
* XXX - expose to userland for now.
*/
struct schedstate_percpu {
- struct timeval spc_runtime; /* time curproc started running */
- __volatile int spc_schedflags; /* flags; see below */
- u_int spc_schedticks; /* ticks for schedclock() */
- u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */
- u_char spc_curpriority; /* usrpri of curproc */
- int spc_rrticks; /* ticks until roundrobin() */
- int spc_pscnt; /* prof/stat counter */
- int spc_psdiv; /* prof/stat divisor */
- struct proc *spc_idleproc; /* idle proc for this cpu */
+ struct timeval spc_runtime; /* time curproc started running */
+ __volatile int spc_schedflags; /* flags; see below */
+ u_int spc_schedticks; /* ticks for schedclock() */
+ u_int64_t spc_cp_time[CPUSTATES];/* CPU state statistics */
+ u_char spc_curpriority; /* usrpri of curproc */
+ int spc_rrticks; /* ticks until roundrobin() */
+ int spc_pscnt; /* prof/stat counter */
+ int spc_psdiv; /* prof/stat divisor */
+ struct proc *spc_idleproc; /* idle proc for this cpu */
- u_int spc_nrun; /* procs on the run queues */
- fixpt_t spc_ldavg; /* shortest load avg. for this cpu */
+ u_int spc_nrun; /* procs on the run queues */
+ fixpt_t spc_ldavg; /* shortest load avg. for this cpu */
TAILQ_HEAD(prochead, proc) spc_qs[SCHED_NQS];
volatile uint32_t spc_whichqs;
#ifdef notyet
- struct proc *spc_reaper; /* dead proc reaper */
+ struct proc *spc_reaper; /* dead proc reaper */
#endif
LIST_HEAD(,proc) spc_deadproc;
};
@@ -123,35 +124,35 @@ struct schedstate_percpu {
#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */
#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD)
-#define SCHED_PPQ (128 / SCHED_NQS) /* priorities per queue
*/
-#define NICE_WEIGHT 2 /* priorities per nice level */
-#define ESTCPULIM(e) min((e), NICE_WEIGHT * PRIO_MAX - SCHED_PPQ)
+#define SCHED_PPQ ((MAXPRI + 1) / SCHED_NQS) /* priorities per queue */
+#define NICE_WEIGHT 2 /* priorities per nice level */
+#define ESTCPULIM(e) min((e), NICE_WEIGHT * PRIO_MAX - SCHED_PPQ)
extern int schedhz; /* ideally: 16 */
extern int rrticks_init; /* ticks per roundrobin() */
struct proc;
-void schedclock(struct proc *);
+void schedclock(struct proc *);
struct cpu_info;
-void roundrobin(struct cpu_info *);
+void roundrobin(struct cpu_info *);
-void sched_init_cpu(struct cpu_info *);
-void sched_exit(struct proc *);
-void mi_switch(void);
-void cpu_switchto(struct proc *, struct proc *);
-struct proc *sched_chooseproc(void);
-struct cpu_info *sched_choosecpu(struct proc *);
-struct cpu_info *sched_choosecpu_fork(struct proc *parent, int);
-void cpu_idle_enter(void);
-void cpu_idle_cycle(void);
-void cpu_idle_leave(void);
-void sched_peg_curproc(struct cpu_info *ci);
+void sched_init_cpu(struct cpu_info *);
+void sched_exit(struct proc *);
+void mi_switch(void);
+void cpu_switchto(struct proc *, struct proc *);
+struct proc *sched_chooseproc(void);
+struct cpu_info *sched_choosecpu(struct proc *);
+struct cpu_info *sched_choosecpu_fork(struct proc *parent, int);
+void cpu_idle_enter(void);
+void cpu_idle_cycle(void);
+void cpu_idle_leave(void);
+void sched_peg_curproc(struct cpu_info *ci);
#define curcpu_is_idle() (curcpu()->ci_schedstate.spc_whichqs == 0)
-void sched_init_runqueues(void);
-void setrunqueue(struct proc *);
-void remrunqueue(struct proc *);
+void sched_init_runqueues(void);
+void setrunqueue(struct proc *);
+void remrunqueue(struct proc *);
/* Inherit the parent's scheduler history */
#define scheduler_fork_hook(parent, child) do {
\