This might be a very stupid question.
I have experience with embedded software on bare-metal and just started with FREERTOS. However I don't really understand why one would use FREERTOS instead of the built in interrupt mechanism. The goal of multitasking is to give the impression some sort of parallellization is going on on a single core (similar to multithreading). If you have a main function that is running specific functions continuously, next to this you can have different interrupt routines with different importance levels that can interrupt that main function and then return to the main function. With an embedded OS you have some task running and it then gets interrupted to run a task with a higher priority.
So far in my eyes the final result seems pretty similar, could someone correct me and/or give some more explanation?
while(1)
loop approach is not good anymore. Then you are writing a simple task scheduler. Then you discover that you need priorities for the task, and smarter scheduling. Also you have developed a bunch of HAL libraries at this point. And suddenly you discover that you want to run this program on different hardware. So you make it portable. And.. guess what? You have developed a simple OS. Now the question. Why? You have a ready made one containing this stuff. \$\endgroup\$while(1)
loop on the bottom. but as a simple example take task preemption mechanism. Assume that you have a low priority, but a heavy taks taking much time and a high priority realtime task. So the first task can run on the "background" yielding the execution to the second task whenever it is required. Can you simply achieve this with a while loop? no. But OS has it out of the box. \$\endgroup\$