From: Matthew Dillon Date: Thu, 20 Sep 2012 04:33:54 +0000 (-0700) Subject: kernel - Add lwkt_yield_quick() X-Git-Tag: v3.2.0~107 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/405041228ac2bcf301b9dedd7aa46e88618842c5 kernel - Add lwkt_yield_quick() * Add a quick version of lwkt_yield() which does not try to round-robin LWKT threads at the same priority. --- diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index bc6f22c2d1..7414c2c8b5 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -1199,6 +1199,28 @@ lwkt_yield(void) } } +/* + * The quick version processes pending interrupts and higher-priority + * LWKT threads but will not round-robin same-priority LWKT threads. + */ +void +lwkt_yield_quick(void) +{ + globaldata_t gd = mycpu; + thread_t td = gd->gd_curthread; + + if ((gd->gd_reqflags & RQF_IDLECHECK_MASK) && td->td_nest_count < 2) + splz(); + if (lwkt_resched_wanted()) { + if (TAILQ_FIRST(&gd->gd_tdrunq) == td) { + clear_lwkt_resched(); + } else { + lwkt_schedule_self(curthread); + lwkt_switch(); + } + } +} + /* * This yield is designed for kernel threads with a user context. * diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 66c126e4d2..4e244a5b5f 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -444,6 +444,7 @@ extern void lwkt_schedule_self(thread_t); extern void lwkt_deschedule(thread_t); extern void lwkt_deschedule_self(thread_t); extern void lwkt_yield(void); +extern void lwkt_yield_quick(void); extern void lwkt_user_yield(void); extern void lwkt_token_wait(void); extern void lwkt_hold(thread_t);