aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/proc.h
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2004-12-30 20:52:44 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2004-12-30 20:52:44 +0000
commitf5c157d986f052962aae4063ea973a62af59c5d7 (patch)
treef5f18f239d1f27cced3e6b80e05c76ba4ebcfce8 /sys/sys/proc.h
parent99b808f461ad76423a31be5ce314136af8b46c18 (diff)
downloadsrc-f5c157d986f052962aae4063ea973a62af59c5d7.tar.gz
src-f5c157d986f052962aae4063ea973a62af59c5d7.zip
Rework the interface between priority propagation (lending) and the
schedulers a bit to ensure more correct handling of priorities and fewer priority inversions: - Add two functions to the sched(9) API to handle priority lending: sched_lend_prio() and sched_unlend_prio(). The turnstile code uses these functions to ask the scheduler to lend a thread a set priority and to tell the scheduler when it thinks it is ok for a thread to stop borrowing priority. The unlend case is slightly complex in that the turnstile code tells the scheduler what the minimum priority of the thread needs to be to satisfy the requirements of any other threads blocked on locks owned by the thread in question. The scheduler then decides where the thread can go back to normal mode (if it's normal priority is high enough to satisfy the pending lock requests) or it it should continue to use the priority specified to the sched_unlend_prio() call. This involves adding a new per-thread flag TDF_BORROWING that replaces the ULE-only kse flag for priority elevation. - Schedulers now refuse to lower the priority of a thread that is currently borrowing another therad's priority. - If a scheduler changes the priority of a thread that is currently sitting on a turnstile, it will call a new function turnstile_adjust() to inform the turnstile code of the change. This function resorts the thread on the priority list of the turnstile if needed, and if the thread ends up at the head of the list (due to having the highest priority) and its priority was raised, then it will propagate that new priority to the owner of the lock it is blocked on. Some additional fixes specific to the 4BSD scheduler include: - Common code for updating the priority of a thread when the user priority of its associated kse group has been consolidated in a new static function resetpriority_thread(). One change to this function is that it will now only adjust the priority of a thread if it already has a time sharing priority, thus preserving any boosts from a tsleep() until the thread returns to userland. Also, resetpriority() no longer calls maybe_resched() on each thread in the group. Instead, the code calling resetpriority() is responsible for calling resetpriority_thread() on any threads that need to be updated. - schedcpu() now uses resetpriority_thread() instead of just calling sched_prio() directly after it updates a kse group's user priority. - sched_clock() now uses resetpriority_thread() rather than writing directly to td_priority. - sched_nice() now updates all the priorities of the threads after the group priority has been adjusted. Discussed with: bde Reviewed by: ups, jeffr Tested on: 4bsd, ule Tested on: i386, alpha, sparc64
Notes
Notes: svn path=/head/; revision=139453
Diffstat (limited to 'sys/sys/proc.h')
-rw-r--r--sys/sys/proc.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 542f62fd5023..6278ae8f50e8 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -327,6 +327,7 @@ struct thread {
* Flags kept in td_flags:
* To change these you MUST have the scheduler lock.
*/
+#define TDF_BORROWING 0x00000001 /* Thread is borrowing pri from another. */
#define TDF_UNUSED0 0x00000001 /* --available -- */
#define TDF_INPANIC 0x00000002 /* Caused a panic, let it drive crashdump. */
#define TDF_SINTR 0x00000008 /* Sleep is interruptible. */