Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Papyrus-RT/User/User Guide/Thread Assignments"

m
(Clarified that the .controllers file is used by the code generator and incorporated in the resulting executable. It is no longer necessary to have the ".controller" file co-located with the final executable image.)
 
Line 6: Line 6:
 
This topic addresses how to create a multithreaded application by assigning a particular capsule or capsule part to an OS thread.
 
This topic addresses how to create a multithreaded application by assigning a particular capsule or capsule part to an OS thread.
  
=Assigning Threads at Startup=
+
=Assigning Threads=
  
 
An easy way to assign threads, at least until the [[Papyrus-RT/Releases#Papyrus-RT_MVP3_.28v_TBD.29_-_Build_it_and_they_will_come.21|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.
 
An easy way to assign threads, at least until the [[Papyrus-RT/Releases#Papyrus-RT_MVP3_.28v_TBD.29_-_Build_it_and_they_will_come.21|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.
Line 12: Line 12:
 
===Thread Assignment File name and Location===
 
===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 directory/folder as the model (the same folder as the .uml file) to be recognized on startup.
+
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===
 
===Thread Assignment File Structure===

Latest revision as of 14:31, 19 February 2018

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