This is a C++ working code example of using multithreading with semaphores and mutex.

I did not find a C++ example of multithreading for the BeagleBoardBlack when I searched before.
Since I need to validate the use of threading, semaphores, and mutexes on my new BeagleBoardBlack I developed this working example.
This example creates 2 different styles of threads (a) the method is the thread and (b) the method started as a thread creates a class which the method in turn invokes.
I use the second style because I want to easily detect termination problems with the thread.
Most of the threads I start for my projects should never return and if they do then I need to detect the reason behind the termination.
I have a particular coding style that I have developed over the years (45+) of writing code and teaching programming.
You are free to modify the code as you see fit.
My development environment is as follows:
a) Host computer is PC running Windows 7x64
b) My source editor is Eclipse and I use the created a remote Configuration to upload and test my programs on the BeagleBoardBlack.
c) Tool chain is SysGCC
d) I run Putty as an additional terminal to the BeagleBoardBlack.
e) These are the two sites I use to help me get up and running
(1) http://www.michaelhleonard.com/cross-compile-for-beaglebone-black/
(2) http://learn.adafruit.com/beaglebone-black-installing-operating-systems?view=all
If you have any questions, drop me an email at ireland94@embarqmail.com

TestMultiThreading.cpp (5.45 KB)

Hi,
  if you are going to use multi-threading and locking mechanisms with
C++, I would recommend using the new functionality from C++11, there's a
lot of documentation and examples about it. If you prefer, somehow
equivalent, you could use the boost threading library.
    regards,
      Nuno