1.4 KiB
1.4 KiB
Inter-Process Communication (IPC) with the FSFW
IPC is a necessary tool to let software entities communicate with each other. In general, for any Software, there are two primary ways for software entities to communicate with each other:
- Shared Memory. If memory is shared between threads or tasks, memory access needs to be protected with a lock, also commonly called Mutex.
- Message Passing. Usually, OSes provide some way of passing messages between threads safely.
Ín this workshop, we will look at both available ways to perform IPC with the FSFW. I recommend to read the thread and mutual exclusion chapters of the the concurrency chapter provided by the isocpp if you are completely new to concurrency in C++.
1. Sharing state between two threads
Subtasks
- Create two threads which run some tasks with a period of 50ms using the
std::thread
API - Introduce a static global
uint32_t
variable calledSHARED_VARIABLE
- Increment the variable in both threads, but ensure that the access
is protected by a
std::mutex
. You can also use thestd::lock_guard
which is a RAII-style helper object.