dtgee
dtgee

Reputation: 1272

Is it possible to have priority inversion with two processes?

The usual example gives three processes, but shouldn't it be possible with only two processes?

Let us assume we have two processes, p3 and p1. p3's priority is less than p1. p3 is currently in the critical section using a resource which p1 will need. p1 comes along, and p3 gets preempted by p1. But, p3 was holding a resource which p1 needed to run.

Isn't this an example of priority inversion with 2 processes?

Upvotes: 1

Views: 300

Answers (1)

Carl Norum
Carl Norum

Reputation: 225272

No, it's not. p1 will just block when it tries to acquire the resource, which will allow p3 to run again, finish using the resource, and relinquish it, thereby unblocking p1.

Wikipedia's example of a priority inversion is a good reference that describes why three tasks are required.

Upvotes: 2

Related Questions