aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1994-10-02 04:48:21 +0000
committerDavid Greenman <dg@FreeBSD.org>1994-10-02 04:48:21 +0000
commit7216391e4989b73d7794fefd88de3d13f3c9f075 (patch)
tree785ddd71e44efc1a10d0f791acee35f5daa8dbe5 /sys
parent723ff3e087a31bac37386d56a5875cb53106c35a (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/cpu_switch.S107
-rw-r--r--sys/amd64/amd64/genassym.c5
-rw-r--r--sys/amd64/amd64/swtch.s107
-rw-r--r--sys/i386/i386/genassym.c5
-rw-r--r--sys/i386/i386/swtch.s107
-rw-r--r--sys/kern/init_main.c5
-rw-r--r--sys/kern/init_sysent.c4
-rw-r--r--sys/kern/kern_fork.c7
-rw-r--r--sys/kern/kern_proc.c3
-rw-r--r--sys/kern/kern_resource.c79
-rw-r--r--sys/kern/kern_synch.c5
-rw-r--r--sys/kern/syscalls.c2
-rw-r--r--sys/kern/syscalls.master4
-rw-r--r--sys/sys/proc.h5
-rw-r--r--sys/sys/rtprio.h30
-rw-r--r--sys/sys/syscall-hide.h2
-rw-r--r--sys/sys/syscall.h2
17 files changed, 376 insertions, 103 deletions
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index ad83a9a2e0c7..ab405002e702 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.13 1994/09/02 05:58:51 davidg Exp $
+ * $Id: swtch.s,v 1.14 1994/10/01 02:56:03 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -59,10 +59,11 @@
* queues.
*/
.data
- .globl _curpcb, _whichqs, _whichrtqs
+ .globl _curpcb, _whichqs, _whichrtqs, _whichidqs
_curpcb: .long 0 /* pointer to curproc's PCB area */
_whichqs: .long 0 /* which run queues have data */
_whichrtqs: .long 0 /* which realtime run queues have data */
+_whichidqs: .long 0 /* which idletime run queues have data */
.globl _qs,_cnt,_panic
.comm _noproc,4
@@ -84,10 +85,15 @@ ENTRY(setrunqueue)
pushl $set2
call _panic
set1:
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
- je set1_nort
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ je set_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* realtime priority? */
+ jne set_id /* must be idle priority */
+
+set_rt:
btsl %edx,_whichrtqs /* set q full bit */
shll $3,%edx
addl $_rtqs,%edx /* locate q hdr */
@@ -97,7 +103,19 @@ set1:
movl %eax,P_BACK(%edx)
movl %eax,P_FORW(%ecx)
ret
-set1_nort:
+
+set_id:
+ btsl %edx,_whichidqs /* set q full bit */
+ shll $3,%edx
+ addl $_idqs,%edx /* locate q hdr */
+ movl %edx,P_FORW(%eax) /* link process on tail of q */
+ movl P_BACK(%edx),%ecx
+ movl %ecx,P_BACK(%eax)
+ movl %eax,P_BACK(%edx)
+ movl %eax,P_FORW(%ecx)
+ ret
+
+set_nort: /* Normal (RTOFF) code */
movzbl P_PRI(%eax),%edx
shrl $2,%edx
btsl %edx,_whichqs /* set q full bit */
@@ -119,13 +137,17 @@ set2: .asciz "setrunqueue"
*/
ENTRY(remrq)
movl 4(%esp),%eax
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
je rem_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ jne rem_id
+
btrl %edx,_whichrtqs /* clear full bit, panic if clear already */
jb rem1rt
- pushl $rem3
+ pushl $rem3rt
call _panic
rem1rt:
pushl %edx
@@ -146,6 +168,31 @@ rem1rt:
rem2rt:
movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
ret
+rem_id:
+ btrl %edx,_whichidqs /* clear full bit, panic if clear already */
+ jb rem1id
+ pushl $rem3id
+ call _panic
+rem1id:
+ pushl %edx
+ movl P_FORW(%eax),%ecx /* unlink process */
+ movl P_BACK(%eax),%edx
+ movl %edx,P_BACK(%ecx)
+ movl P_BACK(%eax),%ecx
+ movl P_FORW(%eax),%edx
+ movl %edx,P_FORW(%ecx)
+ popl %edx
+ movl $_idqs,%ecx
+ shll $3,%edx
+ addl %edx,%ecx
+ cmpl P_FORW(%ecx),%ecx /* q still has something? */
+ je rem2id
+ shrl $3,%edx /* yes, set bit as still full */
+ btsl %edx,_whichidqs
+rem2id:
+ movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
+ ret
+
rem_nort:
movzbl P_PRI(%eax),%edx
shrl $2,%edx
@@ -174,6 +221,8 @@ rem2:
ret
rem3: .asciz "remrq"
+rem3rt: .asciz "remrq.rt"
+rem3id: .asciz "remrq.id"
sw0: .asciz "cpu_switch"
/*
@@ -200,10 +249,12 @@ _idle:
ALIGN_TEXT
idle_loop:
cli
- cmpl $0,_whichrtqs
+ cmpl $0,_whichrtqs /* real-time queue */
jne sw1a
- cmpl $0,_whichqs
+ cmpl $0,_whichqs /* normal queue */
jne nortqr
+ cmpl $0,_whichidqs /* 'idle' queue */
+ jne idqr
#ifdef APM
call _apm_cpu_idle
call _apm_cpu_busy
@@ -269,7 +320,6 @@ sw1a:
testl %edi,%edi
jz nortqr /* no realtime procs */
-rt2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
jz nortqr /* no proc on rt q - try normal ... */
@@ -298,12 +348,13 @@ rt3:
jmp swtch_com
/* old sw1a */
+/* Normal process priority's */
nortqr:
movl _whichqs,%edi
2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
- jz _idle /* if none, idle */
+ jz idqr /* if none, idle */
/* XX update whichqs? */
btrl %ebx,%edi /* clear q full status */
@@ -326,6 +377,36 @@ nortqr:
btsl %ebx,%edi /* nope, set to indicate not empty */
3:
movl %edi,_whichqs /* update q status */
+ jmp swtch_com
+
+idqr: /* was sw1a */
+ movl _whichidqs,%edi /* pick next p. from idqs */
+
+ /* XXX - bsf is sloow */
+ bsfl %edi,%ebx /* find a full q */
+ jz _idle /* no proc, idle */
+
+ /* XX update whichqs? */
+ btrl %ebx,%edi /* clear q full status */
+ leal _idqs(,%ebx,8),%eax /* select q */
+ movl %eax,%esi
+
+#ifdef DIAGNOSTIC
+ cmpl P_FORW(%eax),%eax /* linked to self? (e.g. not on list) */
+ je badsw /* not possible */
+#endif
+
+ movl P_FORW(%eax),%ecx /* unlink from front of process q */
+ movl P_FORW(%ecx),%edx
+ movl %edx,P_FORW(%eax)
+ movl P_BACK(%ecx),%eax
+ movl %eax,P_BACK(%edx)
+
+ cmpl P_FORW(%ecx),%esi /* q empty */
+ je id3
+ btsl %ebx,%edi /* nope, set to indicate not empty */
+id3:
+ movl %edi,_whichidqs /* update q status */
swtch_com:
movl $0,%eax
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
index c5685444d972..1ea7ba1e1714 100644
--- a/sys/amd64/amd64/genassym.c
+++ b/sys/amd64/amd64/genassym.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
- * $Id: genassym.c,v 1.11 1994/09/12 11:38:03 davidg Exp $
+ * $Id: genassym.c,v 1.12 1994/10/02 01:28:38 rgrimes Exp $
*/
#include <sys/param.h>
@@ -78,7 +78,8 @@ main()
printf("#define\tVM_PMAP %d\n", &vms->vm_pmap);
printf("#define\tP_ADDR %d\n", &p->p_addr);
printf("#define\tP_PRI %d\n", &p->p_priority);
- printf("#define\tP_RTPRIO %d\n", &p->p_rtprio);
+ printf("#define\tP_RTPRIO_TYPE %d\n", &p->p_rtprio.type);
+ printf("#define\tP_RTPRIO_PRIO %d\n", &p->p_rtprio.prio);
printf("#define\tP_STAT %d\n", &p->p_stat);
printf("#define\tP_WCHAN %d\n", &p->p_wchan);
printf("#define\tP_FLAG %d\n", &p->p_flag);
diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s
index ad83a9a2e0c7..ab405002e702 100644
--- a/sys/amd64/amd64/swtch.s
+++ b/sys/amd64/amd64/swtch.s
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.13 1994/09/02 05:58:51 davidg Exp $
+ * $Id: swtch.s,v 1.14 1994/10/01 02:56:03 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -59,10 +59,11 @@
* queues.
*/
.data
- .globl _curpcb, _whichqs, _whichrtqs
+ .globl _curpcb, _whichqs, _whichrtqs, _whichidqs
_curpcb: .long 0 /* pointer to curproc's PCB area */
_whichqs: .long 0 /* which run queues have data */
_whichrtqs: .long 0 /* which realtime run queues have data */
+_whichidqs: .long 0 /* which idletime run queues have data */
.globl _qs,_cnt,_panic
.comm _noproc,4
@@ -84,10 +85,15 @@ ENTRY(setrunqueue)
pushl $set2
call _panic
set1:
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
- je set1_nort
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ je set_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* realtime priority? */
+ jne set_id /* must be idle priority */
+
+set_rt:
btsl %edx,_whichrtqs /* set q full bit */
shll $3,%edx
addl $_rtqs,%edx /* locate q hdr */
@@ -97,7 +103,19 @@ set1:
movl %eax,P_BACK(%edx)
movl %eax,P_FORW(%ecx)
ret
-set1_nort:
+
+set_id:
+ btsl %edx,_whichidqs /* set q full bit */
+ shll $3,%edx
+ addl $_idqs,%edx /* locate q hdr */
+ movl %edx,P_FORW(%eax) /* link process on tail of q */
+ movl P_BACK(%edx),%ecx
+ movl %ecx,P_BACK(%eax)
+ movl %eax,P_BACK(%edx)
+ movl %eax,P_FORW(%ecx)
+ ret
+
+set_nort: /* Normal (RTOFF) code */
movzbl P_PRI(%eax),%edx
shrl $2,%edx
btsl %edx,_whichqs /* set q full bit */
@@ -119,13 +137,17 @@ set2: .asciz "setrunqueue"
*/
ENTRY(remrq)
movl 4(%esp),%eax
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
je rem_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ jne rem_id
+
btrl %edx,_whichrtqs /* clear full bit, panic if clear already */
jb rem1rt
- pushl $rem3
+ pushl $rem3rt
call _panic
rem1rt:
pushl %edx
@@ -146,6 +168,31 @@ rem1rt:
rem2rt:
movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
ret
+rem_id:
+ btrl %edx,_whichidqs /* clear full bit, panic if clear already */
+ jb rem1id
+ pushl $rem3id
+ call _panic
+rem1id:
+ pushl %edx
+ movl P_FORW(%eax),%ecx /* unlink process */
+ movl P_BACK(%eax),%edx
+ movl %edx,P_BACK(%ecx)
+ movl P_BACK(%eax),%ecx
+ movl P_FORW(%eax),%edx
+ movl %edx,P_FORW(%ecx)
+ popl %edx
+ movl $_idqs,%ecx
+ shll $3,%edx
+ addl %edx,%ecx
+ cmpl P_FORW(%ecx),%ecx /* q still has something? */
+ je rem2id
+ shrl $3,%edx /* yes, set bit as still full */
+ btsl %edx,_whichidqs
+rem2id:
+ movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
+ ret
+
rem_nort:
movzbl P_PRI(%eax),%edx
shrl $2,%edx
@@ -174,6 +221,8 @@ rem2:
ret
rem3: .asciz "remrq"
+rem3rt: .asciz "remrq.rt"
+rem3id: .asciz "remrq.id"
sw0: .asciz "cpu_switch"
/*
@@ -200,10 +249,12 @@ _idle:
ALIGN_TEXT
idle_loop:
cli
- cmpl $0,_whichrtqs
+ cmpl $0,_whichrtqs /* real-time queue */
jne sw1a
- cmpl $0,_whichqs
+ cmpl $0,_whichqs /* normal queue */
jne nortqr
+ cmpl $0,_whichidqs /* 'idle' queue */
+ jne idqr
#ifdef APM
call _apm_cpu_idle
call _apm_cpu_busy
@@ -269,7 +320,6 @@ sw1a:
testl %edi,%edi
jz nortqr /* no realtime procs */
-rt2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
jz nortqr /* no proc on rt q - try normal ... */
@@ -298,12 +348,13 @@ rt3:
jmp swtch_com
/* old sw1a */
+/* Normal process priority's */
nortqr:
movl _whichqs,%edi
2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
- jz _idle /* if none, idle */
+ jz idqr /* if none, idle */
/* XX update whichqs? */
btrl %ebx,%edi /* clear q full status */
@@ -326,6 +377,36 @@ nortqr:
btsl %ebx,%edi /* nope, set to indicate not empty */
3:
movl %edi,_whichqs /* update q status */
+ jmp swtch_com
+
+idqr: /* was sw1a */
+ movl _whichidqs,%edi /* pick next p. from idqs */
+
+ /* XXX - bsf is sloow */
+ bsfl %edi,%ebx /* find a full q */
+ jz _idle /* no proc, idle */
+
+ /* XX update whichqs? */
+ btrl %ebx,%edi /* clear q full status */
+ leal _idqs(,%ebx,8),%eax /* select q */
+ movl %eax,%esi
+
+#ifdef DIAGNOSTIC
+ cmpl P_FORW(%eax),%eax /* linked to self? (e.g. not on list) */
+ je badsw /* not possible */
+#endif
+
+ movl P_FORW(%eax),%ecx /* unlink from front of process q */
+ movl P_FORW(%ecx),%edx
+ movl %edx,P_FORW(%eax)
+ movl P_BACK(%ecx),%eax
+ movl %eax,P_BACK(%edx)
+
+ cmpl P_FORW(%ecx),%esi /* q empty */
+ je id3
+ btsl %ebx,%edi /* nope, set to indicate not empty */
+id3:
+ movl %edi,_whichidqs /* update q status */
swtch_com:
movl $0,%eax
diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index c5685444d972..1ea7ba1e1714 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
- * $Id: genassym.c,v 1.11 1994/09/12 11:38:03 davidg Exp $
+ * $Id: genassym.c,v 1.12 1994/10/02 01:28:38 rgrimes Exp $
*/
#include <sys/param.h>
@@ -78,7 +78,8 @@ main()
printf("#define\tVM_PMAP %d\n", &vms->vm_pmap);
printf("#define\tP_ADDR %d\n", &p->p_addr);
printf("#define\tP_PRI %d\n", &p->p_priority);
- printf("#define\tP_RTPRIO %d\n", &p->p_rtprio);
+ printf("#define\tP_RTPRIO_TYPE %d\n", &p->p_rtprio.type);
+ printf("#define\tP_RTPRIO_PRIO %d\n", &p->p_rtprio.prio);
printf("#define\tP_STAT %d\n", &p->p_stat);
printf("#define\tP_WCHAN %d\n", &p->p_wchan);
printf("#define\tP_FLAG %d\n", &p->p_flag);
diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s
index ad83a9a2e0c7..ab405002e702 100644
--- a/sys/i386/i386/swtch.s
+++ b/sys/i386/i386/swtch.s
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.13 1994/09/02 05:58:51 davidg Exp $
+ * $Id: swtch.s,v 1.14 1994/10/01 02:56:03 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -59,10 +59,11 @@
* queues.
*/
.data
- .globl _curpcb, _whichqs, _whichrtqs
+ .globl _curpcb, _whichqs, _whichrtqs, _whichidqs
_curpcb: .long 0 /* pointer to curproc's PCB area */
_whichqs: .long 0 /* which run queues have data */
_whichrtqs: .long 0 /* which realtime run queues have data */
+_whichidqs: .long 0 /* which idletime run queues have data */
.globl _qs,_cnt,_panic
.comm _noproc,4
@@ -84,10 +85,15 @@ ENTRY(setrunqueue)
pushl $set2
call _panic
set1:
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
- je set1_nort
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ je set_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* realtime priority? */
+ jne set_id /* must be idle priority */
+
+set_rt:
btsl %edx,_whichrtqs /* set q full bit */
shll $3,%edx
addl $_rtqs,%edx /* locate q hdr */
@@ -97,7 +103,19 @@ set1:
movl %eax,P_BACK(%edx)
movl %eax,P_FORW(%ecx)
ret
-set1_nort:
+
+set_id:
+ btsl %edx,_whichidqs /* set q full bit */
+ shll $3,%edx
+ addl $_idqs,%edx /* locate q hdr */
+ movl %edx,P_FORW(%eax) /* link process on tail of q */
+ movl P_BACK(%edx),%ecx
+ movl %ecx,P_BACK(%eax)
+ movl %eax,P_BACK(%edx)
+ movl %eax,P_FORW(%ecx)
+ ret
+
+set_nort: /* Normal (RTOFF) code */
movzbl P_PRI(%eax),%edx
shrl $2,%edx
btsl %edx,_whichqs /* set q full bit */
@@ -119,13 +137,17 @@ set2: .asciz "setrunqueue"
*/
ENTRY(remrq)
movl 4(%esp),%eax
- cmpl $RTPRIO_RTOFF,P_RTPRIO(%eax) /* Realtime process ? */
+ cmpw $RTP_PRIO_NORMAL,P_RTPRIO_TYPE(%eax) /* normal priority process? */
je rem_nort
- movl P_RTPRIO(%eax),%edx
+ movzwl P_RTPRIO_PRIO(%eax),%edx
+
+ cmpw $RTP_PRIO_REALTIME,P_RTPRIO_TYPE(%eax) /* normal priority process? */
+ jne rem_id
+
btrl %edx,_whichrtqs /* clear full bit, panic if clear already */
jb rem1rt
- pushl $rem3
+ pushl $rem3rt
call _panic
rem1rt:
pushl %edx
@@ -146,6 +168,31 @@ rem1rt:
rem2rt:
movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
ret
+rem_id:
+ btrl %edx,_whichidqs /* clear full bit, panic if clear already */
+ jb rem1id
+ pushl $rem3id
+ call _panic
+rem1id:
+ pushl %edx
+ movl P_FORW(%eax),%ecx /* unlink process */
+ movl P_BACK(%eax),%edx
+ movl %edx,P_BACK(%ecx)
+ movl P_BACK(%eax),%ecx
+ movl P_FORW(%eax),%edx
+ movl %edx,P_FORW(%ecx)
+ popl %edx
+ movl $_idqs,%ecx
+ shll $3,%edx
+ addl %edx,%ecx
+ cmpl P_FORW(%ecx),%ecx /* q still has something? */
+ je rem2id
+ shrl $3,%edx /* yes, set bit as still full */
+ btsl %edx,_whichidqs
+rem2id:
+ movl $0,P_BACK(%eax) /* zap reverse link to indicate off list */
+ ret
+
rem_nort:
movzbl P_PRI(%eax),%edx
shrl $2,%edx
@@ -174,6 +221,8 @@ rem2:
ret
rem3: .asciz "remrq"
+rem3rt: .asciz "remrq.rt"
+rem3id: .asciz "remrq.id"
sw0: .asciz "cpu_switch"
/*
@@ -200,10 +249,12 @@ _idle:
ALIGN_TEXT
idle_loop:
cli
- cmpl $0,_whichrtqs
+ cmpl $0,_whichrtqs /* real-time queue */
jne sw1a
- cmpl $0,_whichqs
+ cmpl $0,_whichqs /* normal queue */
jne nortqr
+ cmpl $0,_whichidqs /* 'idle' queue */
+ jne idqr
#ifdef APM
call _apm_cpu_idle
call _apm_cpu_busy
@@ -269,7 +320,6 @@ sw1a:
testl %edi,%edi
jz nortqr /* no realtime procs */
-rt2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
jz nortqr /* no proc on rt q - try normal ... */
@@ -298,12 +348,13 @@ rt3:
jmp swtch_com
/* old sw1a */
+/* Normal process priority's */
nortqr:
movl _whichqs,%edi
2:
/* XXX - bsf is sloow */
bsfl %edi,%ebx /* find a full q */
- jz _idle /* if none, idle */
+ jz idqr /* if none, idle */
/* XX update whichqs? */
btrl %ebx,%edi /* clear q full status */
@@ -326,6 +377,36 @@ nortqr:
btsl %ebx,%edi /* nope, set to indicate not empty */
3:
movl %edi,_whichqs /* update q status */
+ jmp swtch_com
+
+idqr: /* was sw1a */
+ movl _whichidqs,%edi /* pick next p. from idqs */
+
+ /* XXX - bsf is sloow */
+ bsfl %edi,%ebx /* find a full q */
+ jz _idle /* no proc, idle */
+
+ /* XX update whichqs? */
+ btrl %ebx,%edi /* clear q full status */
+ leal _idqs(,%ebx,8),%eax /* select q */
+ movl %eax,%esi
+
+#ifdef DIAGNOSTIC
+ cmpl P_FORW(%eax),%eax /* linked to self? (e.g. not on list) */
+ je badsw /* not possible */
+#endif
+
+ movl P_FORW(%eax),%ecx /* unlink from front of process q */
+ movl P_FORW(%ecx),%edx
+ movl %edx,P_FORW(%eax)
+ movl P_BACK(%ecx),%eax
+ movl %eax,P_BACK(%edx)
+
+ cmpl P_FORW(%ecx),%esi /* q empty */
+ je id3
+ btsl %ebx,%edi /* nope, set to indicate not empty */
+id3:
+ movl %edi,_whichidqs /* update q status */
swtch_com:
movl $0,%eax
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 41693b21ed1e..44129c1d0f81 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
- * $Id: init_main.c,v 1.10 1994/09/13 14:46:47 dfr Exp $
+ * $Id: init_main.c,v 1.11 1994/09/25 19:33:33 phk Exp $
*/
#include <sys/param.h>
@@ -165,7 +165,8 @@ main(framep)
p->p_flag = P_INMEM | P_SYSTEM;
p->p_stat = SRUN;
p->p_nice = NZERO;
- p->p_rtprio = RTPRIO_RTOFF;
+ p->p_rtprio.type = RTP_PRIO_NORMAL;
+ p->p_rtprio.prio = 0;
bcopy("swapper", p->p_comm, sizeof ("swapper"));
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index 8ac5eaef03a2..15a3fb9f3c7e 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -2,7 +2,7 @@
* System call switch table.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from $Id: syscalls.master,v 1.9 1994/09/18 20:39:50 wollman Exp $
+ * created from $Id: syscalls.master,v 1.10 1994/09/28 22:44:47 wollman Exp $
*/
#include <sys/param.h>
@@ -446,7 +446,7 @@ struct sysent sysent[] = {
{ 2, setdomainname }, /* 163 = setdomainname */
{ 1, uname }, /* 164 = uname */
{ 2, sysarch }, /* 165 = sysarch */
- { 2, rtprio }, /* 166 = rtprio */
+ { 3, rtprio }, /* 166 = rtprio */
{ 0, nosys }, /* 167 = nosys */
{ 0, nosys }, /* 168 = nosys */
#ifdef SYSVSEM
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 61e2f50d7a0f..94c9e223d47b 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
- * $Id: kern_fork.c,v 1.5 1994/08/18 22:35:00 wollman Exp $
+ * $Id: kern_fork.c,v 1.6 1994/09/01 05:12:38 davidg Exp $
*/
#include <sys/param.h>
@@ -269,11 +269,6 @@ again:
p2->p_estcpu = p1->p_estcpu;
/*
- * copy the realtime attibute
- */
- p2->p_rtprio = p1->p_rtprio;
-
- /*
* This begins the section where we must prevent the parent
* from being swapped.
*/
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 989cf1cb4104..f9c3d7b9a740 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_proc.c 8.4 (Berkeley) 1/4/94
- * $Id: kern_proc.c,v 1.5 1994/09/01 05:12:39 davidg Exp $
+ * $Id: kern_proc.c,v 1.6 1994/09/25 19:33:41 phk Exp $
*/
#include <sys/param.h>
@@ -53,6 +53,7 @@
struct prochd qs[NQS]; /* as good a place as any... */
struct prochd rtqs[NQS]; /* Space for REALTIME queues too */
+struct prochd idqs[NQS]; /* Space for IDLE queues too */
volatile struct proc *allproc; /* all processes */
struct proc *zombproc; /* just zombies */
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 704c5019cb6a..6d2c27429ff4 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_resource.c,v 1.4 1994/09/01 05:12:40 davidg Exp $
+ * $Id: kern_resource.c,v 1.5 1994/09/25 19:33:42 phk Exp $
*/
#include <sys/param.h>
@@ -195,8 +195,9 @@ donice(curp, chgp, n)
/* rtprio system call */
struct rtprio_args {
- int who;
- pid_t rtprio;
+ int function;
+ pid_t pid;
+ struct rtprio *rtprio;
};
/*
@@ -211,45 +212,55 @@ rtprio(curp, uap, retval)
int *retval;
{
register struct proc *p;
- register int n = uap->rtprio;
register struct pcred *pcred = curp->p_cred;
+ struct rtprio rtp;
+ int error;
+
+ error = copyin(uap->rtprio, &rtp, sizeof(struct rtprio));
+ if (error)
+ return (error);
- if (uap->who == 0)
+ if (uap->pid == 0)
p = curp;
else
- p = pfind(uap->who);
+ p = pfind(uap->pid);
if (p == 0)
return (ESRCH);
- if (n == RTPRIO_NOCHG) {
- *retval = (int)p->p_rtprio;
- return(0); }
-
- if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
- pcred->pc_ucred->cr_uid != p->p_ucred->cr_uid &&
- pcred->p_ruid != p->p_ucred->cr_uid)
- return (EPERM);
-
- if (n == RTPRIO_RTOFF) {
- if(suser(pcred->pc_ucred, &curp->p_acflag)&& !uap->who)
- return (EPERM);
- p->p_rtprio = RTPRIO_RTOFF;
- *retval = RTPRIO_RTOFF;
- return (0); }
-
- if (n > RTPRIO_MAX)
- return (EINVAL);
- if (n < RTPRIO_MIN)
- return (EINVAL);
- if (suser(pcred->pc_ucred, &curp->p_acflag))
- return (EPERM);
-
- p->p_rtprio = n;
-
- *retval = (int)p->p_rtprio;
- return (0);
-};
+ switch (uap->function) {
+ case RTP_LOOKUP:
+ return (copyout(&p->p_rtprio, uap->rtprio, sizeof(struct rtprio)));
+ case RTP_SET:
+ if (pcred->pc_ucred->cr_uid && pcred->p_ruid &&
+ pcred->pc_ucred->cr_uid != p->p_ucred->cr_uid &&
+ pcred->p_ruid != p->p_ucred->cr_uid)
+ return (EPERM);
+ /* disallow setting rtprio in most cases if not superuser */
+ if (suser(pcred->pc_ucred, &curp->p_acflag)) {
+ /* can't set someone else's */
+ if (uap->pid)
+ return (EPERM);
+ /* can't set realtime priority */
+ if (rtp.type == RTP_PRIO_REALTIME)
+ return (EPERM);
+ }
+ switch (rtp.type) {
+ case RTP_PRIO_REALTIME:
+ case RTP_PRIO_NORMAL:
+ case RTP_PRIO_IDLE:
+ if (rtp.prio > RTP_PRIO_MAX)
+ return (EINVAL);
+ p->p_rtprio = rtp;
+ return (0);
+ default:
+ return (EINVAL);
+ }
+
+ default:
+ return (EINVAL);
+ }
+}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
struct setrlimit_args {
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index c74469f11a49..a7d3774f4dc0 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.6 (Berkeley) 1/21/94
- * $Id: kern_synch.c,v 1.4 1994/09/01 05:12:41 davidg Exp $
+ * $Id: kern_synch.c,v 1.5 1994/09/25 19:33:44 phk Exp $
*/
#include <sys/param.h>
@@ -609,6 +609,7 @@ rqinit()
for (i = 0; i < NQS; i++) {
qs[i].ph_link = qs[i].ph_rlink = (struct proc *)&qs[i];
rtqs[i].ph_link = rtqs[i].ph_rlink = (struct proc *)&rtqs[i];
+ idqs[i].ph_link = idqs[i].ph_rlink = (struct proc *)&idqs[i];
}
}
@@ -662,7 +663,7 @@ resetpriority(p)
{
register unsigned int newpriority;
- if (p->p_rtprio == RTPRIO_RTOFF) {
+ if (p->p_rtprio.type == RTP_PRIO_NORMAL) {
newpriority = PUSER + p->p_estcpu / 4 + 2 * p->p_nice;
newpriority = min(newpriority, MAXPRI);
p->p_usrpri = newpriority;
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index 56eecbc3d499..eb9491c69dde 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -2,7 +2,7 @@
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from $Id: syscalls.master,v 1.9 1994/09/18 20:39:50 wollman Exp $
+ * created from $Id: syscalls.master,v 1.10 1994/09/28 22:44:47 wollman Exp $
*/
char *syscallnames[] = {
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index d9a471e6de65..0e7c986a3099 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
- $Id: syscalls.master,v 1.9 1994/09/18 20:39:50 wollman Exp $
+ $Id: syscalls.master,v 1.10 1994/09/28 22:44:47 wollman Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
;
; System call name/number master file.
@@ -219,7 +219,7 @@
163 STD 2 BSD setdomainname
164 STD 1 BSD uname
165 STD 2 BSD sysarch
-166 STD 2 BSD rtprio
+166 STD 3 BSD rtprio
167 UNIMPL 0 NOHIDE nosys
168 UNIMPL 0 NOHIDE nosys
#ifdef SYSVSEM
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 6155408a15bf..541ef9581657 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.8 (Berkeley) 1/21/94
- * $Id: proc.h,v 1.7 1994/08/28 16:53:35 bde Exp $
+ * $Id: proc.h,v 1.8 1994/09/01 05:12:52 davidg Exp $
*/
#ifndef _SYS_PROC_H_
@@ -156,6 +156,7 @@ struct proc {
struct sysentvec *p_sysent; /* System call dispatch information. */
+ struct rtprio p_rtprio; /* realtime priority */
/* End area that is copied on creation. */
#define p_endcopy p_thread
int p_thread; /* Id for this "thread"; Mach glue. XXX */
@@ -165,7 +166,6 @@ struct proc {
u_short p_xstat; /* Exit status for wait; also stop signal. */
u_short p_acflag; /* Accounting flags. */
struct rusage *p_ru; /* Exit information. XXX */
- u_long p_rtprio; /* realtime priority */
};
#define p_session p_pgrp->pg_session
@@ -248,6 +248,7 @@ extern struct proc *initproc, *pageproc; /* Process slots for init, pager. */
#define NQS 32 /* 32 run queues. */
extern struct prochd qs[];
extern struct prochd rtqs[];
+extern struct prochd idqs[];
extern int whichqs; /* Bit mask summary of non-empty Q's. */
struct prochd {
struct proc *ph_link; /* Linked list of running processes. */
diff --git a/sys/sys/rtprio.h b/sys/sys/rtprio.h
index 7638f9bb4454..9a22a34806b7 100644
--- a/sys/sys/rtprio.h
+++ b/sys/sys/rtprio.h
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: rtprio.h,v 1.1 1994/09/01 05:12:53 davidg Exp $
*/
#ifndef _SYS_RTPRIO_H_
@@ -37,16 +37,34 @@
/*
* Process realtime-priority specifications to rtprio.
*/
-#define RTPRIO_MIN 0 /* relativ-FASTEST */
-#define RTPRIO_MAX 31 /* relativ-SLOWEST */
-#define RTPRIO_NOCHG 100 /* look only */
-#define RTPRIO_RTOFF 101 /* NON-realtime */
+
+/* priority types */
+#define RTP_PRIO_REALTIME 0
+#define RTP_PRIO_NORMAL 1
+#define RTP_PRIO_IDLE 2
+
+/* priority range */
+#define RTP_PRIO_MIN 0 /* Highest priority */
+#define RTP_PRIO_MAX 31 /* Lowest priority */
+
+/*
+ * rtprio() syscall functions
+ */
+#define RTP_LOOKUP 0
+#define RTP_SET 1
+
+#ifndef LOCORE
+struct rtprio {
+ u_short type;
+ u_short prio;
+};
+#endif
#ifndef KERNEL
#include <sys/cdefs.h>
__BEGIN_DECLS
-int rtprio __P((int, int));
+int rtprio __P((int, pid_t, struct rtprio *));
__END_DECLS
#endif /* !KERNEL */
#endif /* !_SYS_RTPRIO_H_ */
diff --git a/sys/sys/syscall-hide.h b/sys/sys/syscall-hide.h
index e09c89342008..b326435f645d 100644
--- a/sys/sys/syscall-hide.h
+++ b/sys/sys/syscall-hide.h
@@ -2,7 +2,7 @@
* System call hiders.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from $Id: syscalls.master,v 1.9 1994/09/18 20:39:50 wollman Exp $
+ * created from $Id: syscalls.master,v 1.10 1994/09/28 22:44:47 wollman Exp $
*/
HIDE_POSIX(fork)
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index 5d53601f562b..c57bb7e2368e 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -2,7 +2,7 @@
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from $Id: syscalls.master,v 1.9 1994/09/18 20:39:50 wollman Exp $
+ * created from $Id: syscalls.master,v 1.10 1994/09/28 22:44:47 wollman Exp $
*/
#define SYS_syscall 0