Handshake
Two FreeRTOS tasks need to share a counter. Each task increments the counter, prints its name and the counter value, then yields. Without proper synchronization the output is unpredictable.
Your job: create a mutex, two tasks, and coordinate access so the output is deterministic.
Task A (priority 1) and Task B (priority 1) each run 3 iterations. On every iteration a task takes the mutex, increments the shared counter, prints its line, gives the mutex, then delays. After both tasks finish, Task B prints "DONE".
Each task prints its line as "<task letter>:<counter value>". With strict A-then-B alternation and a properly shared counter, the six task lines interleave A and B with the counter ascending 1 through 6, then the final DONE line prints.
Grading checks that exact alternation, starting with Task A. The mutex keeps the counter consistent, but it does not by itself decide which task prints first: the alternation depends on which task begins running first and on each task yielding after its turn. The simulation runs for 500 ms of virtual time, and all required output must appear within that window.
Available FreeRTOS APIs: xSemaphoreCreateMutex() xSemaphoreTake(mutex, timeout) xSemaphoreGive(mutex) xTaskCreate(function, name, stack_size, param, priority, handle) vTaskStartScheduler() vTaskDelay(ticks) pdMS_TO_TICKS(ms) portMAX_DELAY configMINIMAL_STACK_SIZE