From: Matthew Dillon Date: Fri, 2 Oct 2009 18:04:46 +0000 (-0700) Subject: lwkt - Add lwkt_setpri_initial() X-Git-Tag: v2.5.1~23 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/03bd0a5ed39b6b9a731f41c2ff793fa6a728ec39 lwkt - Add lwkt_setpri_initial() * Add a lwkt_setpri_initial() call which has no cpu restriction but which requires the thread to not be scheduled. --- diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index a5177633cd..f4b1f8b615 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -1295,6 +1295,23 @@ lwkt_setpri(thread_t td, int pri) crit_exit(); } +/* + * Set the initial priority for a thread prior to it being scheduled for + * the first time. The thread MUST NOT be scheduled before or during + * this call. The thread may be assigned to a cpu other then the current + * cpu. + * + * Typically used after a thread has been created with TDF_STOPPREQ, + * and before the thread is initially scheduled. + */ +void +lwkt_setpri_initial(thread_t td, int pri) +{ + KKASSERT(pri >= 0); + KKASSERT((td->td_flags & TDF_RUNQ) == 0); + td->td_pri = (td->td_pri & ~TDPRI_MASK) + pri; +} + void lwkt_setpri_self(int pri) { diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 7cc006fd50..5c26a1c7fd 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -385,6 +385,7 @@ extern void lwkt_token_pool_init(void); extern lwkt_token_t lwkt_token_pool_get(void *); extern void lwkt_setpri(thread_t, int); +extern void lwkt_setpri_initial(thread_t, int); extern void lwkt_setpri_self(int); extern int lwkt_check_resched(thread_t); extern void lwkt_setcpu_self(struct globaldata *);