cvs commit: src/sys/conf options.i386 src/sys/i386/i386 machdep.c mp_machdep.c pmap.c swtch.s src/sys/i386/include md_var.h pmap.h smp.h src/sys/i386/isa apic_vector.s intr_machdep.h src/sys/kern kern_switch.c kern_synch.c kern_thr.c kern_thread.c subr_witness.c ...

Andrew Gallatin gallatin at cs.duke.edu
Thu Apr 3 11:24:52 PST 2003


Peter Wemm [peter at wemm.org] wrote:
> Nate Lawson wrote:
<..>
> > Shouldn't there be a "if (thread == curthread) return;" in the scheduling
> > code somewhere?
> 
> There is now. :-)
> 
>         newtd = choosethread();
>         if (td != newtd)
>                 cpu_switch(td, newtd);  /* SHAZAM!! */
> #ifdef SWTCH_OPTIM_STATS
>         else
>                 stupid_switch++;
> #endif
> 
> sparc64's cpu_switch() already optimized this case.  i386 didn't.  I haven't
> checked alpha/ia64 yet, but they're still using the old no-args API.

I think alpha has this feature:

LEAF(cpu_switch, 1)
<..>
        CALL(choosethread)                      /* can't return NULL */
        mov     v0, s2                          /* s2 = new thread  */
        ldq     s3, TD_MD_PCBPADDR(s2)          /* s3 = new pcbpaddr */

        /*
         * Check to see if we're switching to ourself.  If we are,
         * don't bother loading the new context.
<..>

        cmpeq   s0, s2, t0                      /* oldthread == newthread? */
        bne     t0, Lcs7                        /* Yes!  Skip! */

Drew


More information about the cvs-src mailing list