CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Principles of Computers 19 th Lecture Pavel Ježek, Ph.D.

Slides:



Advertisements
Similar presentations
Processing Order: Cooperative vs. Preemptive Process B2 Process A Process C Process B1 Process D Process A (low priority, cyclic) Process C (high priority,
Advertisements

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
CSE 522 Real-Time Scheduling (3)
1 CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
EEE 435 Principles of Operating Systems Interprocess Communication Pt II (Modern Operating Systems 2.3)
1 Operating Systems, 122 Practical Session 5, Synchronization 1.
1 Overview Assignment 10: hints  Deadlocks & Scheduling Assignment 9: solution  Scheduling.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Semaphores, mutexes and condition variables. semaphores Two types – Binary – 0 or 1 – Counting 0 to n Wait – decrements > 0 forces a wait Post or signal.
Monitors CSCI 444/544 Operating Systems Fall 2008.
MicroC/OS-II Embedded Systems Design and Implementation.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Experience with Processes and Monitors in Mesa
CS 153 Design of Operating Systems Spring 2015 Midterm Review.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
SYNCHRONIZATION Module-4. scheduling Scheduling is an operating system mechanism that arbitrate CPU resources between running tasks. Different scheduling.
Lecture Topics: 11/13 Semaphores Deadlock Scheduling.
CSS430 CPU Scheduling1 Textbook Ch6 These slides were compiled from the Applied OSC textbook slides (Silberschatz, Galvin, and Gagne) and the instructor’s.
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
TANNENBAUM SECTION 2.3 INTERPROCESS COMMUNICATION OPERATING SYSTEMS.
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS. NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
RSVP-TE Extensions to Notification for Shared Mesh Protection CCAMP WG, IETF 81th draft-he-ccamp-notification-shared-mesh-protection-00 Wenjuan He
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Principles of Computers 20 th Lecture Pavel Ježek, Ph.D.
Lecture 6 Page 1 CS 111 Summer 2013 Concurrency Solutions and Deadlock CS 111 Operating Systems Peter Reiher.
CHAPTER 7 CONCURRENT SOFTWARE Copyright © 2000, Daniel W. Lewis. All Rights Reserved.
Implementing Lock. From the Previous Lecture  The “too much milk” example shows that writing concurrent programs directly with load and store instructions.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.)
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
Chapter 3 RTOS Concepts And Definitions Department of Computer Science Hsu Hao Chen Professor Hsung-Pin Chang.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Outlines  Introduction  Kernel Structure  Porting.
Real-Time Operating Systems RTOS For Embedded systems.
One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head.
A brief intro to: Parallelism, Threads, and Concurrency
Sarah Diesburg Operating Systems COP 4610
Topics Covered What is Real Time Operating System (RTOS)
Threads and Scheduling
Principles of Computers 21st Lecture
Scheduling in µC/OS-III
COT 4600 Operating Systems Spring 2011
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Lecture 2 Part 2 Process Synchronization
CGS 3763 Operating Systems Concepts Spring 2013
Implementing Mutual Exclusion
LINKED LISTS.
Kernel Synchronization I
Implementing Mutual Exclusion
NET 424: REAL-TIME SYSTEMS (Practical Part)
Thomas E. Anderson, Brian N. Bershad,
CS333 Intro to Operating Systems
Real-Time Process Scheduling Concepts, Design and Implementations
CS703 – Advanced Operating Systems
CGS 3763 Operating Systems Concepts Spring 2013
Real-Time Process Scheduling Concepts, Design and Implementations
Monitors and Inter-Process Communication
Presentation transcript:

CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Principles of Computers 19 th Lecture Pavel Ježek, Ph.D.

Thread T1 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Thread T1 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Thread T1 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Thread T1 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Thread T1 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem;

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; Context Switch

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; Context Switch next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; Context Switch next prev OtherItem Still a valid doubly-linked list

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Threads T1 and T2 Inserting into A Doubly-Linked List next prev AfterThis next prev NewItem next prev BeforeThis T1: NewItem^.prev := AfterThis; T1: AfterThis^.next^.prev := NewItem; T2: OtherItem^.prev := AfterThis; T2: AfterThis^.next^.prev := OtherItem; T2: OtherItem^.next := AfterThis^.next; T2: AfterThis.next := OtherItem; T1: NewItem^.next := AfterThis^.next; T1: AfterThis.next := NewItem; next prev OtherItem

Is It Thread Safe? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; end;

Is It Thread Safe? In Cooperative Multitasking? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin Yield; { allowed here } NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; no Yield here! NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; Yield; { allowed here } end;

Is It Thread Safe? In Preemptive Multitasking? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; end;

Critical Section Is It Thread Safe? In Preemptive Multitasking? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; end;

Is It Thread Safe? In Preemptive Multitasking? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin asm cli; NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; asm sti; end;

Critical Section Is It Thread Safe? In Preemptive Multitasking? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; end;

Is It Thread Safe? Using Locks? next prev AfterThis next prev NewItem next prev BeforeThis procedure InsertItem(AfterThis : Node; NewItem : Node) begin Lock(l); NewItem^.prev := AfterThis; AfterThis^.next^.prev := NewItem; NewItem^.next := AfterThis^.next; AfterThis.next := NewItem; Unlock(l); end;

Legend Data Thread lifetime Running thread Thread waiting for an unspecified event Thread waiting for a lock Thread ready to run Successful thread action Failed thread action Action asynchronous from the point of view of a target thread Unlocked lock Locked lock

Fighting for A Lock Lock A state: unlocked Lock A state: unlocked RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3

Fighting for A Lock Lock A state: unlocked Lock A state: unlocked RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A

Fighting for A Lock Lock A state: held by T1 Lock A state: held by T1 RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A

Fighting for A Lock Lock A state: unlocked Lock A state: unlocked RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A

Fighting for A Lock Lock A state: unlocked Lock A state: unlocked RUNNING Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up

RUNNING RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN Fighting for A Lock Lock A state: unlocked Lock A state: unlocked Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up

RUNNING RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN Fighting for A Lock Lock A state: unlocked Lock A state: unlocked Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up RUN lock A

RUNNING RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN RTR READY-TO-RUN Fighting for A Lock Lock A state: held by T2 Lock A state: held by T2 Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up RUN lock A

READY-TO-RUN RUNNING RTR READY-TO-RUN RTR READY-TO-RUN Fighting for A Lock Lock A state: held by T2 Lock A state: held by T2 Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up lock A RUNNING RUN lock A

READY-TO-RUN RUNNING RTR READY-TO-RUN RTR READY-TO-RUN Fighting for A Lock Lock A state: held by T2 Lock A state: held by T2 Thread 1 RUNNING Thread 2 RUNNING Thread 3 lock A WAITING for Lock A lock A W. A unlock A wake up lock A RUNNING RUN lock A WAITING for A

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN preemption (forced context switch)

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING wake up

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING wake up RTR READY-TO-RUN RTR READY-TO-RUN preemption (forced context switch)

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING RTR READY-TO-RUN RTR READY-TO-RUN

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING RTR READY-TO-RUN RTR READY-TO-RUN lock A

Priority Inversion Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 WAITING Thread 1 WAITING Thread 2 RUNNING Thread 3 lock A wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING wake up RTR READY-TO-RUN RTR READY-TO-RUN RUNNING RTR READY-TO-RUN RTR READY-TO-RUN lock A WAITING for Lock A RUNNING context switch

Priority Inversion: Solution? Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAIT priority boost RTR READY-TO-RUN RTR READY-TO-RUN

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T3 Lock A state: held by T3 Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A wake up

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A RUN restore old priority RTR READY-TO-RUN RTR READY-TO-RUN

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A RUN RTR READY-TO-RUN RTR READY-TO-RUN preemption (forced context switch) RUN RTR READY-TO-RUN RTR READY-TO-RUN

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: unlocked Lock A state: unlocked Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A RUN RTR READY-TO-RUN RTR READY-TO-RUN RUN RTR READY-TO-RUN RTR READY-TO-RUN lock A

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Lock A state: held by T1 Lock A state: held by T1 Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A RUN RTR READY-TO-RUN RTR READY-TO-RUN RUN RTR READY-TO-RUN RTR READY-TO-RUN lock A

Solution? Priority Boost Priority Level 0 (highest) Priority Level 1 Priority Level 2 Priority Level 3 Priority Level 4 (lowest) Thread 1 Thread 2 Thread 3 READY-TO-RUN RUNNING lock A READY-TO-RUN WAITING for Lock A RTR READY-TO-RUN RTR READY-TO-RUN RUNNING unlock A RUN RTR READY-TO-RUN RTR READY-TO-RUN RUNNING READY-TO-RUN Lock A state: held by T1 Lock A state: held by T1 lock A