Non-Blocking Write Protocol NBW:

Similar documents
Concurrent Control with "Readers" and "Writers"

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Concurrency: Deadlock and Starvation

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Threads. Threads The Thread Model (1) CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5

Scheduling Algorithm and Analysis


Concurrency. Chapter 5

ENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS

Last Class: Monitors. Real-world Examples

More Types of Synchronization 11/29/16

Aperiodic Servers (Issues)

Midterm Exam Solutions Amy Murphy 28 February 2001

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

SSC - Concurrency and Multi-threading Advanced topics about liveness

Chapters 5 and 6 Concurrency

Process Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Concept of a process

Midterm Exam. October 20th, Thursday NSC

Last Class: Deadlocks. Where we are in the course

Synchronization Classic Problems

Reference Model and Scheduling Policies for Real-Time Systems

Exam Review TexPoint fonts used in EMF.

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Chapter 6 Concurrency: Deadlock and Starvation

Concurrency: Deadlock and Starvation. Chapter 6

CS370 Operating Systems

The Real-time Specification for Java

Back to RTOS. CSE466 Autumn 00-1

Global shared variables. Message passing paradigm. Communication Ports. Port characteristics. Sending a message 07/11/2018

Chapter 6 Concurrency: Deadlock and Starvation

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }

Synchronization COMPSCI 386

2. Introduction to Software for Embedded Systems

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Multiprocessor System. Multiprocessor Systems. Bus Based UMA. Types of Multiprocessors (MPs) Cache Consistency. Bus Based UMA. Chapter 8, 8.

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

Department of CSIT ( G G University, Bilaspur ) Model Answer 2013 (Even Semester) - AR-7307

Efficient Adaptations of the Non-Blocking Buffer for Event Message Communication

CSC501 Operating Systems Principles. Process Synchronization

Multiprocessor Systems. COMP s1

Operating Systems (1DT020 & 1TT802)

CSE 153 Design of Operating Systems

Lecture 9: Midterm Review

IV. Process Synchronisation

Concurrency pros and cons. Concurrent Programming Problems. Mutual Exclusion. Concurrency is good for users

Multiprocessor and Real- Time Scheduling. Chapter 10

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

RTOS 101. Understand your real-time applications. with the help of Percepio Tracealyzer

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

Last Class: Deadlocks. Today

A Predictable RTOS. Mantis Cheng Department of Computer Science University of Victoria

CS 153 Design of Operating Systems Winter 2016

Concurrency pros and cons. Concurrent Programming Problems. Linked list example. Linked list example. Mutual Exclusion. Concurrency is good for users

EMERALDS: a small-memory real-time microkernel

Chapter 2 Processes and Threads

CS140 Operating Systems Midterm Review. Feb. 5 th, 2009 Derrick Isaacson

CS370 Operating Systems

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Process Management And Synchronization

Process Synchronization

Introduction to Operating Systems

Chapter 5 Asynchronous Concurrent Execution

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition

PESIT Bangalore South Campus

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Last Class: Synchronization Problems!

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

Operating Systems Antonio Vivace revision 4 Licensed under GPLv3

Asynchronous Communication Mechanisms (ACMs) EECE, Newcastle University

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

(b) External fragmentation can happen in a virtual memory paging system.

CHAPTER NO - 1 : Introduction:

ECE519 Advanced Operating Systems

CSE 306/506 Operating Systems Deadlock. YoungMin Kwon

1.1 CPU I/O Burst Cycle

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Chapter 6: Process Synchronization

VI. Deadlocks. What is a Deadlock? Intended Schedule. Deadlock Problem (1) ???

VI. Deadlocks Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term

Dealing with Issues for Interprocess Communication

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Concurrency: Mutual Exclusion and Synchronization

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

Processes The Process Model. Chapter 2. Processes and Threads. Process Termination. Process Creation

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Process Synchronization

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

Process Synchronization

Transcription:

Non-Blocking Write Protocol NBW: A Solution to a Real-Time Synchronization Problem By: Hermann Kopetz and Johannes Reisinger Presented By: Jonathan Labin March 8 th 2005

Classic Mutual Exclusion Scenario Reader and Writer processes share some piece of memory. Critical sections and semaphores used Scheduling difficult Task can be blocked at critical section Task can be preempted by high priority task Both readers and writers can be blocked at critical sections

Problem Architecture: System Distributed real-time system Each node contains CPU Memory Communication Controller A dual-ported RAM (DPR) Some nodes also have I/O interfaces

Problem Architecture: System

Problem Architecture: Messages Communication Controller serves messages to CPU through DPR State Messages new version of message overwrites the previous Similar to programming language concept of a variable Minimal interval between message instances is known

Problem Architecture: CPU Tasks {T} set of concurrent tasks Task T i c i = maximum execution time d i = relative deadline l i = laxity (=d i -c i ) Tasks are preemptable

Synchronization Each message type is allocated a structure in DPR Communication Controller writes messages to allocated DPR structure each time they are received Real-time tasks running on CPU read messages from structure One writer. Many readers Readers can not simply block since messages are time sensitive

Desired Properties in Solution Safety If a read operation completes successfully, it must be guaranteed that it has read an uncorrupted version of the data structure. Reader does not interfere with other readers Reader does not invalidate a write Write corrupts a read We check after a read to ensure that it was not corrupted by a write

Desired Properties in Solution Timeliness The tasks containing the read operations must complete their execution before their deadlines. This is hard real-time system. Upper bounds must be known to ensure deadlines are not missed

Desired Properties in Solution Non-Blocking The writer can not be blocked by the readers. Information flow: Writer => Reader Readers can be added or removed without effect on the writer Communication Controller simplified: no need for buffer space

The Protocol: The Basics Writer free to write at any time Readers check after a read operation If no write has occurred during the read: success Otherwise, fail and try again To satisfy timeliness, number of read re-tries must have a known upper bound

The Protocol: Define Concurrency Control Field (CCF) for each message structure. Size = 1 word Init: CCF = 0; Reading or changing CCF is atomic R = max word Incrementing beyond R wraps to 0

The Protocol Writer Increment CCF Perform message structure write Increment CCF again. Reader Read CCF Perform message structure read Check CCF for indication of writer interference

The Protocol: Pseudo-Code

Correctness of Safety Property

Schedulability Analysis: Definitions Attributes of messages: d r = max time of a read without retry d w = max time of a write mint = minimum arrival interval of messages Attributes of tasks: c o = max execution without read-retries c n = max execution with read-retries d = deadline l o = min latency without read-retries (d - c o ) l n = min latency with read-retries N i = max number of interferences of read by write operations

Schedulability Analysis: Single Interference Assume read and write about equal: (d r δ) < d w < (d r + δ) for δ «d r Worst case: Interference by one write => max: 3 read-retries Increase execution of reading task by 3d r

Schedulability Analysis: Multiple Interferences A task with a read operation shares the CPU Tasks with higher priority can preempt read Can cause more than one write to interfere Each write that interferes extends task by 3d r c n = c o + 3N i d r l n = l o 3N i d r

Schedulability Analysis: Multiple Interferences Assume that chosen task scheduling algorithm guarantees all tasks complete before deadline. With mint known we can bound worst case number of interferences: N i For a read operation to be interfered by a second write: Preempted by an interval of: mint d w 2d r

Schedulability Analysis: Multiple Interferences

Schedulability Analysis: Multiple Interferences With this we can bound N i : And therefore execution time bounded: Use this execution time for each task when testing Schedulability

Example Execution time extended by.12 msec (4% more than original execution time)

Poor performance Same example Change d rw from 10 µsec to 200 µsec Execution extension grows from 120 µsec (4% increase) to 2400 µsec (80% increase) Not so good

Problems with current Protocol Not possible to handle tasks with low laxity Protocol becomes inefficient when read times become non-negligible compared to total execution time.

Extension to Protocol: Define Allocate more than one buffer per message Buffers written to cyclically Guarantees that reader reads most recent version of message (as of start of read) CCF i used to determine which buffer to use Define bcnt i to be # buffers for message i Range of CCF i must be a multiple of 2*bcnt i

Extension to Protocol: Read/Write Write write to buffers cyclically Each write increments CCF i by 2 Buffer to write to = floor(ccf i / 2) mod bcnt i Read use latest available message Floor(CCF i / 2) mod bcnt i gives current/next write [Floor(CCF i / 2)-1] mod bcnt i gives last write (that is not currently being written)

Extension to Protocol: Idea Cyclic buffer writing => message not overwritten for bcnt i more messages Interference will be much more rare Each write causes CCF + 2 If CCF has been incremented bcnt i *2 times since this message has been written

Extension to the Protocol: Code

Extension to the Protocol: Schedulability Analysis As long as bnct > 1: c n = c o + 1N i d r l n = l o 1N i d r Interference: (bcnt = 2) 1. Write almost finished to buffer 2 2. Read starts from buffer 1 (most recent to read) 3. Write completes to buffer 2 4. Read is delayed 5. Write to buffer 1 begins (wrapping to beginning) 6. Read attempt of buffer 1 ends (corrupted) If bcnt > 2 then bcnt-2 extra writes at #4

Extension to the Protocol: Schedulability Analysis: read delay To cause interference, read: Must last: (bcnt 1) * mint d w Preemption must last: (bcnt 1) * mint - d w d r retry must be preempted by: (bcnt 1)*mint - d r bcnt =2

Schedulability Analysis: Multiple Interferences With this we can bound: And therefore execution time bounded: Use this execution time for each task when testing Schedulability Also check 2*bcnt N i < R (range of CCF)

Example Same example except d rw = 200 First protocol: process extension = 2400 µsec (80% increase in execution time) But now

Questions?