---
date: '2024-12-18'
description: priority inheritance protocol and priority ceiling protocol for real-time scheduling with resource contention and deadlock prevention.
id: PIP and PCP
modified: 2026-06-05 15:08:43 GMT-04:00
tags:
  - sfwr4aa4
title: PIP and PCP
created: '2024-12-18'
published: '2024-12-18'
pageLayout: default
slug: thoughts/university/twenty-four-twenty-five/sfwr-4aa4/PIP-and-PCP
permalink: https://aarnphm.xyz/thoughts/university/twenty-four-twenty-five/sfwr-4aa4/PIP-and-PCP.md
generator:
  quartz: v4.6.0
  hostedProvider: Cloudflare
  baseUrl: aarnphm.xyz
full: https://aarnphm.xyz/llms-full.txt
---
## Priority Inheritance Protocol (PIP)

idea: increase the priorities only upon resource contention

avoid NPCS drawback

would still run into deadlock (think of RR task resource access)

![[thoughts/university/twenty-four-twenty-five/sfwr-4aa4/PIP.webp]]

rules:

- When a task T1 is blocked due to non availability of a resource that it needs, the task T2 that holds the resource and consequently blocks T1, and T2 inherits the current priority of task T1.
- T2 executes at the inherited priority until it releases R.
- Upon the release of R, the priority of T2 returns to the priority that it held when it acquired the resource R

## Priority Ceiling Protocol (PCP)

idea: extends PIP to prevent deadlocks

- If lower priority task TL blocks a higher priority task TH, priority(TL) ← priority(TH)
- When TL releases a resource, it returns to its normal priority if it doesn’t block any task. Or it returns to the highest priority of the tasks waiting for a resource held by TL
- Transitive
  - T1 blocked by T2: priority(T2) ← priority(T1)
  - T2 blocked by T3: priority(T3) ← priority(T1)

`ceiling(R)`: highest priority. Each resource has fixed priority ceiling

![[thoughts/university/twenty-four-twenty-five/sfwr-4aa4/PCP.webp]]

