For faster navigation, this Iframe is preloading the Wikiwand page for 优先级倒置.

优先级倒置

优先级倒置,又称优先级反转优先级逆转优先级翻转,是一种不希望发生的任务调度状态。在该种状态下,一个高优先级任务间接被一个低优先级任务所抢先(preempted),使得两个任务的相对优先级被倒置。

这往往出现在一个高优先级任务等待访问一个被低优先级任务正在使用的临界资源,从而阻塞了高优先级任务;同时,该低优先级任务被一个次高优先级的任务所抢先,从而无法及时地释放该临界资源。这种情况下,该次高优先级任务获得执行权。

在多数个案,发生优先级倒置并不导致直接伤害──高优先级任务的延迟执行不被察觉,最终,低优先级任务释放共享资源。虽然,亦存在很多情况优先级倒置会导致严重问题

举例

[编辑]

在操作系统中,一般情况下,

  1. 进程分优先级,高优先级进程需要执行时可打断现正在执行的低优先级进程;
  2. 普通的临界资源使用方法,如果一个临界资源被获取了,则其它想要获取此资源的程序被阻塞,直到此资源被释放;
  3. 有三个进程(其优先级从高到低分别为T1、T2、T3),有一个临界资源CS(T1与T3会用到)。这时,T3先执行,获取了临界资源CS。然后T2打断T3。接着T1打断T2,但由于CS已被T3获取,因此T1被阻塞,这样T2获得时间片。直到T2执行完毕后,T3接着执行,其释放CS后,T1才能获取CS并执行。这时,我们看T1与T2,虽然T1优先级比T2高,但实际上T2优先于T1执行。这称之为优先级逆转。

参阅

[编辑]

"Introduction to Priority Inversion" by Michael Barr页面存档备份,存于互联网档案馆

{{bottomLinkPreText}} {{bottomLinkText}}
优先级倒置
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?