Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Papyrus-RT/User/User Guide/Thread Assignments

PapyrusForRealTime-Logo-Icon.png




Thread Assignment


Overview

This topic addresses how to create a multithreaded application by assigning a particular capsule or capsule part to an OS thread.

Assigning Threads

An easy way to assign threads, at least until the Build it and they will come MVP becomes available, is to specify the thread assignment in a specially formatted text file, as described in this document.

Thread Assignment File name and Location

This file's name MUST be called "<TopCapsuleName>.controllers" where <TopCapsuleName> is the name of the top capsule (by default it is "Top") and MUST be located in the same folder as the model, that is the same folder as your model's .uml file. The content of the ".controllers" file will then be read and used when you generate and build the model.

Thread Assignment File Structure

The structure of this file is simple and consists of a series of pair assignment:

<<hierarchically qualified model element>> = <<thread name>>

Don't worry about the thread names, each unique name will be assigned to an OS thread, so you can reuse the name to assign multiple model elements to a single thread - or create threads for each model element, the choice is yours.

Specifying elements

A "qualified model element" is always based on the UML-RT building block, the capsule, i.e., a capsule or a capsule part.

A "hierarchically qualified model element" is a string representing a specific "threadable" model element in your model's composition hierarchy. For example, assuming your "top" capsule is named top and top contains a capsule part named aPart, you would assign aPart to a thread by having the following line in the "Top.controllers" file:

Top = Main
Top.aPart = Second

This assigned the Top capsule to the "Main" thread and aPart to the "Second" thread. Note that if Top has another capsule part named "anotherPart", it will be assigned to the same thread as Top, i.e., to the "Main" thread.

Replicated instance specification

If you have a replicated part, you can assign threads to specific elements in the array by using the [] notation to select an instance:

Top = Main
Top.aReplicatedPart[0] = Second
Top.aReplicatedPart[1] = Third

Example

For example, taking the PingPong model from the Getting Started with Papyrus-RT tutorial (and especially this step to see Top's structure), One could assign the Top, pinger, and ponger to different threads by using the following Top.controllers file:

Top = MainThread
Top.pinger = pingerThread
Top.ponger = pongerThread

Back to the top