Subject: Re: C runqueue
To: None <port-i386@netbsd.org>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: port-i386
Date: 11/01/2002 17:38:22
So, the options are:
- use the existing code
- use the C version
- use Charles' untested table version
Are there strong objections to going to C versions? In all likelihood
the runqueue will be redesigned for different schedulers and to improve
the performance on multiprocessor systems anyway.
Charles M. Hannum wrote:
> 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
-- Gregory McGarry <g.mcgarry@ieee.org>