Concept Flow - Rendezvous (sync) pattern
Task A waits at sync point
Task B waits at sync point
Both tasks reached sync
Tasks proceed together
Two tasks wait for each other at a synchronization point, then both continue together.
void taskA(void *pvParameters) {
xSemaphoreTake(syncSemaphore, portMAX_DELAY);
// Critical section after sync
xSemaphoreGive(syncSemaphore);
vTaskDelete(NULL);
}
void taskB(void *pvParameters) {
xSemaphoreTake(syncSemaphore, portMAX_DELAY);
// Critical section after sync
xSemaphoreGive(syncSemaphore);
vTaskDelete(NULL);
}| Step | Task | Action | Semaphore Count | Result |
|---|---|---|---|---|
| 1 | Task A | Waits on semaphore | 0 | Blocks, waiting |
| 2 | Task B | Waits on semaphore | 0 | Blocks, waiting |
| 3 | ISR or Init | Gives semaphore twice | 2 | Semaphore count = 2 |
| 4 | Task A | Takes semaphore | 1 | Unblocks, proceeds |
| 5 | Task B | Takes semaphore | 0 | Unblocks, proceeds |
| 6 | Task A | Gives semaphore | 1 | Semaphore count incremented |
| 7 | Task B | Gives semaphore | 2 | Semaphore count incremented |
| 8 | Both tasks | Delete themselves | 2 | Tasks end |
| 9 | - | - | - | Execution ends |
| Variable | Start | After Step 3 | After Step 4 | After Step 5 | After Step 7 | Final |
|---|---|---|---|---|---|---|
| syncSemaphore count | 0 | 2 | 1 | 0 | 2 | 2 |
Rendezvous pattern in FreeRTOS: - Two tasks wait on a semaphore to sync. - Semaphore count starts at 0; tasks block. - ISR or init gives semaphore twice. - Both tasks take semaphore and proceed together. - Tasks give semaphore back to restore count.
void TaskA(void *pvParameters) {
xSemaphoreGive(SemA);
xSemaphoreTake(SemB, portMAX_DELAY);
// Continue...
}
void TaskB(void *pvParameters) {
xSemaphoreTake(SemA, portMAX_DELAY);
xSemaphoreGive(SemB);
// Continue...
}Pass the test and this pattern moves unknown