Threadx-Priority Inversion

Undesirable situations can occur when two threads with different priorities share a common
resource. Priority inversion is one such situation; it arises when a higher-priority
thread is suspended because a lower-priority thread has acquired a resource needed by
the higher-priority thread. The problem is compounded when the shared resource is not
in use while the higher-priority thread is waiting. This phenomenon may cause priority
inversion time to become nondeterministic and lead to application failure. Consider
Figure 3.7, which shows an example of the priority inversion problem.
In this example, Thread 3 (with the lowest priority) becomes ready. It obtains mutex M
and begins its execution. Some time later, Thread 2 (which has a higher priority)
becomes ready, preempts Thread 3, and begins its execution. Then Thread 1 (which has
the highest priority of all) becomes ready. However, it needs mutex M, which is owned by Thread 3, so it is suspended until mutex M becomes available. Thus, the higher-priority
thread (i.e., Thread 1) must wait for the lower-priority thread (i.e., Thread 2) before it
can continue. During this wait, the resource protected by mutex M is not being used
because Thread 3 has been preempted by Thread 2.
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值