Skip to content

It covers yarp Thread and RateThread classes along with mutex/semaphors

License

Notifications You must be signed in to change notification settings

vvv-school/tutorial_yarp-multithreading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial on YARP Multithreading

This tutorial will guide you to understand and develop a multi-thread module using YARP threads API. After doing this tutorial you will be expected to know how to write a proper multi-thread module, using semaphore and etc.

will guide you to the use

Tutorial

In this tutorial we will develop a YARP module called tutorial_yarp-multithreading to produce a painted image in YARP and send it via YARP port. We will use multiple thread to take advantage of multi core CPUs for faster data processing.

module

Build and Install the code

Follow these steps to build and properly install your module:

$ cd tutorial_yarp-multithreading
$ mkdir build; cd build
$ cmake ../
$ make
$ make install

the make install will install your module (binary, xml files, etc) in the icub Contrib folder which is already setup on your machine.

Running the tutorial application

  • Simply run the yarpmanager and open/run the Tutorial_yarp-multithreading application for the GUI then connect the ports:
$ yarpmanager

you should be able to see the following output on the yarpview:

module

While the module is running, right click on the tutorial_yarp-multithreading and attach to stdout to see the messages printed by the module. Alternatively you can run the yarplogger and monitors the printed messages there. The module continuously print the total processing time to create (paint) the image.

$ tutorial_yarp-multithreading --threads 1 --width 320 --height 240
[INFO]Processing time  37.38 ms 
[INFO]Processing time  37.303 ms 
...

Running tutorial_yarp-multithreading with two threads

Stop the module, double click on the parameters and change the --threads parameter to --threads 2. Or simply run it from the terminal:

$ tutorial_yarp-multithreading --threads 2 --width 320 --height 240
[INFO]Processing time  16.5989 ms 
[INFO]Processing time  16.8562 ms 
...

module

Running tutorial_yarp-multithreading with four threads

Stop the module, double click on the parameters and change the --threads parameter to --threads 4. Or simply run it from the terminal:

$ tutorial_yarp-multithreading --threads 4 --width 320 --height 240
[INFO]Processing time  10.601 ms 
[INFO]Processing time  10.617 ms 
...

module

Note:

this module needs to use semaphores to regulate the access of the different threads to the RF module

module

About

It covers yarp Thread and RateThread classes along with mutex/semaphors

Resources

License

Stars

Watchers

Forks

Packages

No packages published