Subject: Re: C runqueue
To: Gregory McGarry <g.mcgarry@ieee.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: port-i386
Date: 10/23/2002 16:25:21
Basically, I mean the following patch, although I haven't tested it
yet:
Index: locore.s
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/locore.s,v
retrieving revision 1.258
diff -u -r1.258 locore.s
--- locore.s 2002/08/28 09:47:16 1.258
+++ locore.s 2002/10/23 16:28:43
@@ -1667,6 +1667,40 @@
.globl _C_LABEL(sched_whichqs),_C_LABEL(sched_qs)
.globl _C_LABEL(uvmexp),_C_LABEL(panic)
+powerof2:
+ .long 0x00000001
+ .long 0x00000002
+ .long 0x00000004
+ .long 0x00000008
+ .long 0x00000010
+ .long 0x00000020
+ .long 0x00000040
+ .long 0x00000080
+ .long 0x00000100
+ .long 0x00000200
+ .long 0x00000400
+ .long 0x00000800
+ .long 0x00001000
+ .long 0x00002000
+ .long 0x00004000
+ .long 0x00008000
+ .long 0x00010000
+ .long 0x00020000
+ .long 0x00040000
+ .long 0x00080000
+ .long 0x00100000
+ .long 0x00200000
+ .long 0x00400000
+ .long 0x00800000
+ .long 0x01000000
+ .long 0x02000000
+ .long 0x04000000
+ .long 0x08000000
+ .long 0x10000000
+ .long 0x20000000
+ .long 0x40000000
+ .long 0x80000000
+
/*
* void setrunqueue(struct proc *p);
* Insert a process on the appropriate queue. Should be called at splclock().
@@ -1684,9 +1718,10 @@
jne 1f
#endif /* DIAGNOSTIC */
movzbl P_PRIORITY(%eax),%edx
- shrl $2,%edx
- btsl %edx,_C_LABEL(sched_whichqs) # set q full bit
- leal _C_LABEL(sched_qs)(,%edx,8),%edx # locate q hdr
+ andl $-4,%edx
+ movl powerof2(%edx),%ecx
+ orl %ecx,_C_LABEL(sched_whichqs) # set q full bit
+ leal _C_LABEL(sched_qs)(%edx,%edx),%edx # locate q hdr
movl P_BACK(%edx),%ecx
movl %edx,P_FORW(%eax) # link process on tail of q
movl %eax,P_BACK(%edx)
@@ -1710,9 +1745,10 @@
movl 4(%esp),%ecx
movzbl P_PRIORITY(%ecx),%eax
#ifdef DIAGNOSTIC
- shrl $2,%eax
- btl %eax,_C_LABEL(sched_whichqs)
- jnc 1f
+ andl $-4,%eax
+ movl powerof2(%eax),%eax
+ andl _C_LABEL(sched_whichqs),%eax
+ jz 1f
#endif /* DIAGNOSTIC */
movl P_BACK(%ecx),%edx # unlink process
movl $0,P_BACK(%ecx) # zap reverse link to indicate off list
@@ -1722,9 +1758,10 @@
cmpl %ecx,%edx # q still has something?
jne 2f
#ifndef DIAGNOSTIC
- shrl $2,%eax
+ andl $-4,%eax
+ movl powerof2(%eax),%eax
#endif
- btrl %eax,_C_LABEL(sched_whichqs) # no; clear bit
+ subl %eax,_C_LABEL(sched_whichqs) # no; clear bit
2: ret
#ifdef DIAGNOSTIC
1: pushl $3f