For a bared metal MCU, Comparing to the homemade code with background loop plus timer interrupt architecture, what are the benefits of a non-preemptive OS? What among these benefits are attractive enough for a project to adopt a non-preemptive OS, rather than to use homemade code with background loop architecture?
.
Explanation to the Question:
I really appreciate all those have replied my question. I feel the answer has been almost there. I add this explanation to my question here which shows my own consideration and may help to narrow the question or make it more precise.
What I'm trying to do is to understand how to choose the most appropriate RTOS for a project in general.
To achieve this, better understanding of the basic concepts and the most attractive benefits from different kinds of RTOS and the corresponding price will help, since there is no best RTOS for all applications.
I read books about OS a few years ago but I don't have them with me anymore. I searched on the internet before I posted my question here and found this information was most helpful: http://www.ustudy.in/node/5456.
There are a lot other helpful information like the introductions in the website of different RTOS, articles comparing pre-emptive scheduling and non-preemptive scheduling, and etc.
But I didn't find any topic mentioned when to choose a non-preemptive RTOS and when is better just write your own code using timer interrupt and background loop.
I have certain my own answers but I'm not satisfied enough with them.
I really would like to know the answer or view from more expeirenced people, especially in industry practice.
My understanding so far is:
no matter use or not use an OS, certain kind of scheduling codes are always necessary, even it's in the form of code like:
in the timer interrupt which occurs every 10ms
if(it's 10ms)
{
call function A / execute task A;
}
if(it's 50ms)
{
call function B / execute task B;
}
Benefit 1:
A non-preemptive OS designates the way / programming style for the scheduling code, so that engineers can share the same view even if they were not in the same project before. Then with the same view about concept task, engineers can work on different tasks and test them, profile them independently as much as possible.
But how much are we really able to gain from this? If engineers are working in the same project, they can find way share the same view well without using a non-preemptive OS.
If one engineer is from another project or company, he will gain the benefit if he knew the OS before. But if he didn't, then again, it seems not to make big difference for him to learn a new OS or a new piece of code.
Benefit 2:
If the OS code has been well tested, so it saves the time from debugging. This is really a good benefit.
But if the application has only about 5 tasks, I think it's not really messy to write your own code using timer interrupt and background loop.
A non-preemptive OS here is referred to a commercial / free / legacy OS with a non-preemptive scheduler.
When I posted this question, I mainly think of certain OSes like:
(1) KISS Kernel (A Small NonPreemptive RTOS - claimed by its website)
http://www.frontiernet.net/~rhode/kisskern.html
(2) uSmartX (lightweight RTOS - claimed by its website)
(3) FreeRTOS (It's a preemptive RTOS, but as I understand, it can be configured as a non-preemptive RTOS as well)
(4) uC/OS (similar as FreeRTOS)
(5) legacy OS / scheduler code in some companies (usually made and maintained by the company internally)
(Can't add more links because limitation from new StackOverflow account)
As I understand, a non-preemptive OS is a collection of these codes:
(1) a scheduler using non-preemptive strategy.
(2) facilities for inter-task communication, mutex, synchronization and time control.
(3) memory management.
(4) other helpful facilities / libraries like File System, network stack, GUI and etc. (FreeRTOS and uC/OS provides these, but I'm not sure if they still work when the scheduler is configured as non-preemptive)
Some of them are not always there. But the scheduler is a must.