cpp Multithreading in RRF2.05.1
-
I am writing code for an existing project in 2.05.1 (so no RRF3 sadly). I want to run two functions at the same time. In the big picture, I want to move my toolhead in a specific pattern while I have a sensor detecting specific points in the pattern, for calibration of some sort. My intent was to go about this calling one move function and one sense function and having both of them run at the same time, like cpp has multithreading (or concurrent threading). However, I cannot get the standard cpp threading syntax to work in the reprapfirmware project. I am using Eclipse 2018-19 for 2.05.1.
Looking through the existing code, it seems this line is used for this function:
TaskCriticalSectionLocker lock;
Which to my basic understanding would create a concurrent thread for the following code (there is no documentation on this, so that is a pure guess). However, I could not get this line to work as I intended.So, my question is two parts: How do I use the above line correctly? and sub question; is my interpretation of the functionality correct? Secondly, how do I run two functions simultaneously? such as one move, and one sense function. Thanks for any help.
-
@rl_at_berk RRF uses FreeRTOS for task creation and threading. I suggest you read the FreeRTOS documentation. RRF mosty doesn;t call FreeRTOS directly, instead file RTOSIface/RTOSIface.h in the RRFLibraries project contains the declarations of the functions used by RRF for task creation etc.
The TaskCriticalSectionLocker object merely suspends task switching during its lifetime.