FreeRTOS Mutex and Tasks benefits

Hello,

There are 9 tasks in the project I am working on. I defined these tasks by prioritizing them in order of importance using the “xTaskCreateStatic” function. I defined a mutex for 9 tasks using the “xSemaphoreCreateMutexStatic” function and linked all the tasks to this mutex. When my vTaskDelay value is 10ms, the tasks run in order of priority as in the image below. In a software that will be made without using RTOS, the existing tasks can be written one after the other and run in a certain order. My question is, why do we use RTOS in such a situation and how does mutex contribute to the existing system?

Another problem that stuck in my head is the way the same system switches between tasks when I set the vTaskDelay value to 1ms. Below is the image related to this situation. Since I’m new to FreeRTOS, I may have trouble with some concepts. But what is the benefit of the task transitions in 1ms as in the picture below?

Hi and welcome,

this is not a FreeRTOS specific question but one concerning concurrency theory. Your system benefits from concurrency whenever those two conditions hold:

  1. Your tasks are I/O bound, not CPU bound
  2. Your tasks benefit from concurrent execution. If the entire computation crucially depends on all individual computations to finish, you indeed do not gain anything, which in turn implies your modelling of the problem is incorrect.

You also appear to have a misunderstanding about what muteces are for. You may want to catch up on reading about synchronization.

Just to add, this is good book to learn about FreeRTOS concepts - https://www.freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf