Your browser does not support JavaScript! Skip to main content
Free 30-day trial DO-178C Handbook RapiCoupling Preview DO-178C Multicore Training Multicore Resources
Rapita Systems
 

Industry leading verification solutions

View All

Software Verification with RVS

RapiTest - Functional testing RapiCover - Coverage analysis RapiTime - Timing analysis RapiTask - RTOS scheduling visualization RapiCoverZero - Zero-footprint coverage analysis RapiTimeZero - Zero-footprint timing analysis RapiTaskZero - Zero-footprint scheduling analysis RVS Qualification Kits - Tool qualification for DO-178C RapiCouplingPreview - DCCC analysis

Multicore Verification with MACH178

MACH178 Core Pack - Getting started MACH178 Platform Pack - Platform evaluation MACH178 Resource Pack - Interference verification MACH178 Qualification Pack- Tool qualification

Product-related services

Tool Integration Training Consultancy Support

Other Solutions

RTBx - The ultimate data logging solution Sim68020 - Motorola 68020 Simulation

Using Our Solutions

RVS Development roadmap Product life cycle policy RVS Assurance issue policy

Latest from Rapita HQ

Latest news

Rapita Systems Collaborates with Wind River to Break the Multicore Certification Barrier
MACH178 Rapita Systems Launches Next Generation of MACH178 for Multicore
RVS 3.24 accelerates multicore software verification
Rapita Systems and Avionyx Announce Strategic Partnership to Offer Best-in-class Avionics Solutions
View News

Latest from the Rapita blog

The Evolution of DO-178 and ED-12 Standards
Retro gaming with the Sim68020
RVS gets a new timing analysis engine
How to measure stack usage through stack painting with RapiTest
View Blog

Latest discovery pages

Processor How to achieve multicore DO-178C certification with Rapita Systems
Plane How to achieve DO-178C certification with Rapita Systems
Military Drone Certifying Unmanned Aircraft Systems
control_tower DO-278A Guidance: Introduction to RTCA DO-278 approval
View Discovery pages

Upcoming events

DASC 2026
2026-09-13
DO-178C Multicore Virtual Training
2026-09-29
HISC 2026
2026-10-13
Supporting Multicore Interference Analysis using Branch Traces
2026-11-24
View Events

Technical resources for industry professionals

Latest White papers

Mitigation of interference in multicore processors for A(M)C 20-193
Sysgo WP
Developing DO-178C and ED-12C-certifiable multicore software
DO178C Handbook
Efficient Verification Through the DO-178C Life Cycle
View White papers

Latest Videos

Supporting Multicore Interference Analysis using Branch Traces
Multicore Avionics (Aerospace Innovations)
AMACC Rev B & Multicore Certification: What U.S. Defense Programs Need to Know for Airworthiness Success
Certification-Ready Rust: GNAT Pro & RVS for Avionics Standards
View Videos

Latest Case studies

Case Study Front Cover
Multicore timing analysis support for ECSS-E-ST-40C R&D with MACH178
GMV case study front cover
GMV verify ISO26262 automotive software with RVS
Kappa: Verifying Airborne Video Systems for Air-to-Air Refueling using RVS
View Case studies

Other Resources

 Webinars

 Brochures

 Product briefs

 Technical notes

 Research projects

 Flyers

 Multicore resources

Discover Rapita

About us

The company menu

  • Customers
  • Partners & Distributors
  • Research projects
  • Contact us
  • Careers
  • Working at Rapita
  • Subscribe to newsletter

Industries

  Civil Aviation (DO-178C)   Military & Defense   Automotive (ISO 26262)   Space

Standards

  DO-178C   A(M)C 20-193

US office


info@rapitasystems.com Rapita Systems, Inc., 41131 Vincenti Ct., Novi, MI 48375, USA

UK office

+44 (0)1904 413945
info@rapitasystems.com Rapita Systems Ltd., Atlas House, Osbaldwick Link Road, York, YO10 3JB, UK

Spain office

+34 93 351 02 05
info@rapitasystems.com Rapita Systems S.L., Parc UPC, Edificio K2M, c/ Jordi Girona, 1-3, Barcelona 08034, Spain
Back to Top

How to set up safe, portable interprocess communication without interrupt locks

2010-09-30

The approach described here allows non-blocking interprocess communication to take place on a single CPU, via a FIFO, circular buffer. I originally encountered this method of interprocess communication as part of the MASCOT design methodology, as a way of implementing the channel IDA.

To meet the requirements of providing safe interprocess communication without interrupt locks, the following must be true:

  • Both processes can access common memory
  • Communication is one-way, and occurs from one process/thread to another
  • It is possible to write the in/out indices as an atomic action (i.e. as one machine instruction)
  • It is possible to read the in/out indices as an atomic action
  • Writer never attempts to write to a full buffer
  • Reader never attempts to read from a buffer that doesn't contain valid data
  • Adding data into the buffer does not need to be atomic. That is, it is safe to store records or arrays into the queue

The approach relies upon a circular buffer consists of the following elements:

buffer: array of data with 2^n elements 
in, out: unsigned integers as indices with range 0 to (2^(n+1))-1 

Before reading and writing, it is important to test whether the queue is empty or full, respectively. All queue conditions can be found by looking at the result of the following expression:

 buffer_contents = (in - out) % (2^(n+1)) 

The results of this expression are as follows:

buffer_contents == 0: Queue empty
buffer_contents > 0 && buffer_contents < 2^n: Queue
        contains valid data 
buffer_contents == 2^n: Queue is full 
buffer_contents > 2^n: overrun has occurred 

Writing must only take place when the queue is empty or contains some data (buffer_contents is less than 2^n). If this is the case, the following is done:

buffer[in % (2^n)] = data 
in = (in + 1) % (2^(n+1)) 

Reading must only take place if the queue is full or if it contains valid data (buffer_contents is not 0 and is less than or equal to 2^n). To read, the following actions are performed:

data = buffer[out % (2^n)] 
out = (out + 1) % (2^(n+1)) 

How can we be sure this is safe for interprocess communication?

Writing to a queue

If the writer starts by ensuring that the queue is not full (or overrun), the queue will never overrun after the test, because you are the only one capable of filling up the queue.

If the reader can preempt the writer, there are two possible behaviours:

The reader preempts the writer before the incremented value of 'in' is written

or:

The reader preempts the writer after the incremented value of 'in' is written.

Both of these behaviours are safe (i.e. will not result in the reader attempting to read a partly written value).

Reading from a queue

If the reader starts by ensuring the queue is not empty, the queue will never underrun after the test, because the reader is the only thread capable of emptying the queue.

If the writer can preempt the reader, there are two possible behaviours:

The writer preempts the reader before the incremented value of 'out' is written

or:

The writer preempts the reader after the incremented value of 'out' is written.

Both of these behaviours are safe (i.e. will not result in the writer attempting to overwrite a partly read value). Short C implementation:

#define N 4
#define buffer_contents ((in-out)%(1<<(N+1)))

void * buffer[1<<N];
unsigned int in;
unsigned int out;

void enqueue (void * data)
{
	if (buffer_contents==(1<<N)) return; // full
	buffer[in % (1<<N)] = data;
	in = (in + 1) % (1<<(N+1));
}


void * dequeue (void)
{
	void * data;
	if (buffer_contents==0) return NULL; // empty
	data = buffer[out % (1<<N)];
	out = (out + 1) % (1<<(N+1));
	return data;
}

DO-178C webinars

DO178C webinars

White papers


Mitigation of interference in multicore processors for A(M)C 20-193
Sysgo WP
Developing DO-178C and ED-12C-certifiable multicore software
DO178C Handbook
Efficient Verification Through the DO-178C Life Cycle

A Commercial Solution for Safety-Critical Multicore Timing Analysis
  • Solutions
    • Rapita Verification Suite
    • RapiTest
    • RapiCover
    • RapiTime
    • RapiTask
    • MACH178
  • Latest
  • Latest menu

    • News
    • Blog
    • Events
    • Videos
  • Success Stories
  • Success Stories Menu

    • Airbus Defence & Space
    • BAE Systems
    • Cobham
    • Collins Aerospace
    • Leonardo
  • Downloads
  • Downloads menu

    • Brochures
    • Webinars
    • White Papers
    • Case Studies
    • Product briefs
    • Technical notes
    • Software licensing
  • Company
  • Company menu

    • About Rapita
    • Careers
    • Customers
    • Industries
    • Locations
    • Partners
    • Research projects
    • Contact
  • Discover
    • Multicore Timing Analysis
    • Worst Case Execution Time
    • WCET Tools
    • Code coverage for Ada, C & C++
    • MC/DC Coverage
    • Verifying additional code for DO-178C
    • Data Coupling & Control Coupling
    • DO-178C
    • AC 20-193 and AMC 20-193
    • Certifying eVTOL
    • Certifying UAS

All materials © Rapita Systems Ltd. 2026 - All rights reserved | Privacy information | Trademark notice Subscribe to our newsletter