Priority Inversion Problem and Deadlock Situations



Similar documents
REAL TIME OPERATING SYSTEMS. Lesson-10:

Predictable response times in event-driven real-time systems

REAL TIME OPERATING SYSTEMS. Lesson-18:

Chapter 12. Development Tools for Microcontroller Applications

Tasks Schedule Analysis in RTAI/Linux-GPL

Real- Time Scheduling

Programming real-time systems with C/C++ and POSIX

Monitors, Java, Threads and Processes

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Embedded C Programming, Linux, and Vxworks. Synopsis

Chapter 2: OS Overview

Performance Comparison of RTOS

Implementing AUTOSAR Scheduling and Resource Management on an Embedded SMT Processor

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM

CPU Scheduling. CPU Scheduling

Real-time Scheduling of Periodic Tasks (1) Advanced Operating Systems Lecture 2

Processor Scheduling. Queues Recall OS maintains various queues

The Real-Time Operating System ucos-ii

Last Class: Semaphores

Operating Systems Concepts: Chapter 7: Scheduling Strategies

LAB 5: Scheduling Algorithms for Embedded Systems

Exercises : Real-time Scheduling analysis

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

CS414 SP 2007 Assignment 1

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

Lecture 3 Theoretical Foundations of RTOS

OPERATING SYSTEMS DEADLOCKS

Design Patterns in C++

Chapter 9: Distributed Mutual Exclusion Algorithms

Survey of software architectures: function-queue-scheduling architecture and real time OS

Convenience: An OS makes a computer more convenient to use. Efficiency: An OS allows the computer system resources to be used in an efficient manner.

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Concurrent programming in Java

OS OBJECTIVE QUESTIONS

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I)

4. Fixed-Priority Scheduling

Quality of Service su Linux: Passato Presente e Futuro

Discrete-Event Simulation

First-class User Level Threads

Mutual Exclusion using Monitors

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Real Time Programming: Concepts

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

What is best for embedded development? Do most embedded projects still need an RTOS?

Embedded Software Architecture

OPERATING. William Stallings

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

Real Time Operating System for Embedded DSP Applications

REAL TIME OPERATING SYSTEMS. Lesson-3:

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Chapter 6 Concurrent Programming

Introduction to Distributed Systems

Analysis and Comparison of CPU Scheduling Algorithms

REDUCING TIME: SCHEDULING JOB. Nisha Yadav, Nikita Chhillar, Neha jaiswal

ICS Principles of Operating Systems

Long-term monitoring of apparent latency in PREEMPT RT Linux real-time systems

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

3C03 Concurrency: Condition Synchronisation

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Operating System Manual. Realtime Communication System for netx. Kernel API Function Reference.

Processes and Non-Preemptive Scheduling. Otto J. Anshus

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Java Virtual Machine Locks

Licensing for BarTender s Automation Editions. Understanding Printer-Based Licensing WHITE PAPER

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Outline of this lecture G52CON: Concepts of Concurrency

Fundamentalism and the UK NEW INTERNATIONALIST EASIER ENGLISH PRE-INTERMEDIATE READY LESSON

Centralized Systems. A Centralized Computer System. Chapter 18: Database System Architectures

Lecture 6: Semaphores and Monitors

Outline. Review. Inter process communication Signals Fork Pipes FIFO. Spotlights

Embedded Systems. 6. Real-Time Operating Systems

Making the difference between read to output, and read to copy GOING BEYOND BASIC FILE AUDITING FOR DATA PROTECTION

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

JAVA - MULTITHREADING

Introduction to Fractions

Syllabus MCA-404 Operating System - II

6 Synchronization with Semaphores

What is an RTOS? Introduction to Real-Time Operating Systems. So what is an RTOS?(contd)

USING THE FREERTOS REAL TIME KERNEL

Linux Process Scheduling Policy

1 Organization of Operating Systems

COS 318: Operating Systems. Semaphores, Monitors and Condition Variables

Implementing AUTOSAR Scheduling and Resource Management on an Embedded SMT Processor

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Semaphores and Monitors: High-level Synchronization Constructs

Lesson-16: Real time clock DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK

Jive Connects for Openfire

CPU Scheduling. Core Definitions

Operating Systems Lecture #6: Process Management

Cumulative Diagrams: An Example

Synchronization in. Distributed Systems. Cooperation and Coordination in. Distributed Systems. Kinds of Synchronization.

Transcription:

INTER-PROCESS COMMUNICATION AND SYNCHRONISATION: Lesson-11: Priority Inversion Problem and Deadlock Situations 1

1. Priority Inversion 2

Assume Priorities of tasks be in an order such that task I highest priority, task J a lower, and task K the lowest priority. Only tasks I and K share the data and J does not share data with K. Also let tasks I and K alone share a semaphore s ik and not J. 3

Few tasks share a semaphore Why do only a few tasks share a semaphore? Can't all share a semaphore? Answer Worst-case latency becomes too high and may exceed the deadline if all tasks are blocked when one task takes a semaphore. The worst-case latency will be small only if the time taken by the tasks that share the resources is relevant 4

Priority Inversion Situation At an instant t0, suppose task K takes s ik, it does not block task J and blocks only the task I. This happens because only tasks I and K share the data and J does not and I is blocked at instance t0 due to wait for some message and sik. Consider the problem that now arises on selective sharing between K and I. 5

Priority Inversion Situation At next instant t1, let task K become ready first on an interrupt. Now, assume that at next instant t2, task I becomes ready on an interrupt or getting the waiting message. At this instant, K is in the critical section. Therefore, task I cannot start at this instant due to K being in the critical region. 6

Priority Inversion Situation Now, if at next instant t3, some action (event) causes the unblocked higher than K priority task J to run. After instant t3, running task J does not allow the highest priority task I to run because K is not running, and therefore K can't release s ik that it shares with I. 7

Priority Inversion Situation Further, the design of task J may be such that even when s ik is released by task K, it may not let I run. [J runs the codes as if it is in critical section all the time after executing DI.] The J action is now as if J has higher priority than I. This is because K, after entering the critical section and taking the semaphore the OS let the J run, did not share the priority information about I that task I is of higher priority than J. 8

The priority information of another higherpriority task I should have also been inherited by K temporarily, if K waits for I but J does not and J runs when K has still not finished the critical section codes. This did not happen because the given OS was such that it didn t provide for temporary priority inheritance in such situations. Above situation is also called a priority inversion problem Priority Inversion Situation 9

OS Provision for temporary priority inheritance in such situations Some OSes provide for priority inheritance in these situations and thus priority inheritance problem does not occur when using them. A mutex should be a mutually exclusive Boolean function, by using which the critical section is protected from interruption in such a way that the problem of priority inversion does not arise. Mutex is automatically provided in certain RTOS so that it the priority inversion problem does not arise 10

OS Provision for temporary priority inheritance in such situations Mutex is automatically provided with priority inheritance by task on taking it in certain OSes so that it the priority inversion problem does not arise and certain OSes provides for selecting priority inheritance as well as priority sealing options. 11

2. Deadlock Situation 12

Assume Priorities of tasks be such that task H is of highest priority, task I a lower priority and task J the lowest. Two semaphores, SemTok1 and SemTok2. Tasks I and H have a shared resource through SemTok1 only. Tasks I and J have two shared resources through two semaphores, SemTok1 and SemTok2. 13

Deadlock Situation At a next instant t1, being now of a higher priority, the task H interrupts the task I and J after it takes the semaphore SemTok1, and thus blocks both I and J. 14

Deadlock Situation In between the time interval t0 and t1, the SemTok1 was released but SemTok2 was not released during the run of task J. But the latter did not matter as the tasks I and J don t share SemTok2. 15

Deadlock Situation At an instant t2, if H now releases the SemTok1, lets the task I take it. Even then it cannot run because it is also waiting for task J to release the SemTok2. The task J is waiting at a next instant t3, for either H or I to release the SemTok1 because it needs this to again enter a critical section in it. Neither task I can run after instant t3 nor task J. 16

Deadlock Situation Solution There is a circular dependency established between I and J. 17

Deadlock Situation solution On the interrupt by H, the task J, before exiting from the running state, should have been put in queue-front so that later on, it should first take SemTok1, and the task I put in queue next for the same token, then the deadlock would not have occurred 18

Summary 19

We learnt Priority becomes inverted and deadlock (circular dependency) develops in certain situations when using semaphores. Certain OSes provide the solution to this problem of semaphore use by ensuring that these situations do not arise during the concurrent processing of multitasking operations. 20

End of Lesson11 of Chapter 7 on Priority Inversion Problem and Deadlock Situations 21