Forums

Design of uC/OS (uCOS-II) kernel

Started by karthikbalaguru October 14, 2007
Hi,

I got an interesting information from internet and i have some queries
based on it as it is really strange/unbeleivable .

" In a preemptive priority based RTOS, priority inversion problem is
among the major sources of deadline violations. Priority inheritance
protocol is one of the approaches to reduce priority inversion.
Unfortunately, RTOS like uC/OS can't support priority inheritance
protocol since it does not allow kernel to have multiple tasks at the
same priority. "

Is it true that uC/OS does not support multiple tasks of same
priority ?
Any specific reason for such a design of uC/OS kernel ?

Thx in advans,
Karthik Balaguru

On Sun, 14 Oct 2007 00:15:09 -0700, karthikbalaguru
<karthikbalaguru79@gmail.com> wrote:

>Hi, > >I got an interesting information from internet and i have some queries >based on it as it is really strange/unbeleivable . > >" In a preemptive priority based RTOS, priority inversion problem is >among the major sources of deadline violations.
Priority inversions are usually a result of indiscriminate resource locking. By designing the data structures and how they are accessed from different tasks in a proper way, the risk for priority inversions can be eliminated or at least minimized. Minimize the need for locking e.g. by using a server task for each resource (serial line, in-memory data base etc.) or use atomic updates etc.
>Priority inheritance >protocol is one of the approaches to reduce priority inversion.
Better yet, design the application so that it can not have priority inversion problems.
>Unfortunately, RTOS like uC/OS can't support priority inheritance >protocol since it does not allow kernel to have multiple tasks at the >same priority. " > >Is it true that uC/OS does not support multiple tasks of same >priority ? >Any specific reason for such a design of uC/OS kernel ?
When you have two or more tasks at the same priority level, you usually would have to run some kind of round robin scheduling between these. In many simple kernels, the priority levels are fixed (e.g. the order in which they were created at compile or startup time), so the task list is always scanned in the same order with a strict sequence and there is no way to boost temporarily the priority of a single task (as needed by some priority avoidance protocols). Some priority inversion avoidance system might be useful in large systems with libraries form multiple vendors in which you have no control what internal resources each library is locking, but in small systems using some very simple RT kernels, I really do not see any need for any priority inversion avoidance protocol. Paul
On Oct 14, 3:11 pm, Paul Keinanen <keina...@sci.fi> wrote:
> On Sun, 14 Oct 2007 00:15:09 -0700, karthikbalaguru > > <karthikbalagur...@gmail.com> wrote: > >Hi, > > >I got an interesting information from internet and i have some queries > >based on it as it is really strange/unbeleivable . > > >" In a preemptive priority based RTOS, priority inversion problem is > >among the major sources of deadline violations. > > Priority inversions are usually a result of indiscriminate resource > locking. By designing the data structures and how they are accessed > from different tasks in a proper way, the risk for priority inversions > can be eliminated or at least minimized. Minimize the need for locking > e.g. by using a server task for each resource (serial line, in-memory > data base etc.) or use atomic updates etc. > > >Priority inheritance > >protocol is one of the approaches to reduce priority inversion. > > Better yet, design the application so that it can not have priority > inversion problems. > > >Unfortunately, RTOS like uC/OS can't support priority inheritance > >protocol since it does not allow kernel to have multiple tasks at the > >same priority. " > > >Is it true that uC/OS does not support multiple tasks of same > >priority ? > >Any specific reason for such a design of uC/OS kernel ? > > When you have two or more tasks at the same priority level, you > usually would have to run some kind of round robin scheduling between > these. > > In many simple kernels, the priority levels are fixed (e.g. the order > in which they were created at compile or startup time), so the task > list is always scanned in the same order with a strict sequence and > there is no way to boost temporarily the priority of a single task (as > needed by some priority avoidance protocols). > > Some priority inversion avoidance system might be useful in large > systems with libraries form multiple vendors in which you have no > control what internal resources each library is locking, but in small > systems using some very simple RT kernels, I really do not see any > need for any priority inversion avoidance protocol. > > Paul
Hi, I agree to Paul's thought on avoiding the Priority Inversion altogether. Of course "Prevention is better than Cure" they say. However, if you want to get a feel of the Priority Inheritance Protocol and see how it works, try the highest locker priority Protocol. This would give you a sense of how Priority inheritance Protocol avoids Priority Inversion. In Highest locker priority Protocol Once a task takes a semaphore it runs at the highest priority (something that you could implement in uCos-II). I have tried it myself as a student.
"karthikbalaguru" <karthikbalaguru79@gmail.com> wrote in message
news:1192346109.142121.40350@y27g2000pre.googlegroups.com...
> Hi, > > I got an interesting information from internet and i have some queries > based on it as it is really strange/unbeleivable . > > " In a preemptive priority based RTOS, priority inversion problem is > among the major sources of deadline violations. Priority inheritance > protocol is one of the approaches to reduce priority inversion. > Unfortunately, RTOS like uC/OS can't support priority inheritance > protocol since it does not allow kernel to have multiple tasks at the > same priority. " > > Is it true that uC/OS does not support multiple tasks of same > priority ? > Any specific reason for such a design of uC/OS kernel ?
Mucos is a toy. It is not a real OS, but a bare minimum. For that reason it is lacking many useful services. The mucos core is basically the multi level interrupt controller implemented in the software. Each thread is assigned to the fixed priority level; this concept simplifies a lot of things. However one can implement the priority elevation mechanism in mucos by hand. This is possible but slow and cumbersome. Vladimir Vassilevsky DSP and Mixed Signal Consultant www.abvolt.com
In message <x1pQi.58414$Um6.30132@newssvr12.news.prodigy.net>, Vladimir 
Vassilevsky <antispam_bogus@hotmail.com> writes
> >"karthikbalaguru" <karthikbalaguru79@gmail.com> wrote in message >news:1192346109.142121.40350@y27g2000pre.googlegroups.com... >> Hi, >> >> I got an interesting information from internet and i have some queries >> based on it as it is really strange/unbeleivable . >> >> " In a preemptive priority based RTOS, priority inversion problem is >> among the major sources of deadline violations. Priority inheritance >> protocol is one of the approaches to reduce priority inversion. >> Unfortunately, RTOS like uC/OS can't support priority inheritance >> protocol since it does not allow kernel to have multiple tasks at the >> same priority. " >> >> Is it true that uC/OS does not support multiple tasks of same >> priority ? >> Any specific reason for such a design of uC/OS kernel ? > >Mucos is a toy.
Certainly not.
> It is not a real OS, but a bare minimum.
It IS a real OS. Though as you point out a minimal one. At the other end you have things like Vista which many of us would say has many many things not really needed by an OS. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> " In a preemptive priority based RTOS, priority inversion problem is > among the major sources of deadline violations. Priority inheritance > protocol is one of the approaches to reduce priority inversion.
As others have already said, the best way to avoid priority inheritance is to not design it into your system in the first place. Having said that:
> Unfortunately, RTOS like uC/OS can't support priority inheritance > protocol since it does not allow kernel to have multiple tasks at the > same priority. "
As far as I know, this statement is just plain wrong. I don't know whether uC/OS does or does not support priority inheritance, but I don't see why only having one task at each priority would prevent its use, with some care.
> Is it true that uC/OS does not support multiple tasks of same > priority ?
Yes it is true. Again, you are asking questions the answer to which you can find out for yourself by reading the documentation. -- Regards, Richard. + http://www.FreeRTOS.org 13 official architecture ports, 1000 downloads per week. + http://www.SafeRTOS.com Certified by T&#2013265948;V as meeting the requirements for safety related systems.
On Oct 14, 8:56 pm, "FreeRTOS.org" <noe...@address.com> wrote:
> > " In a preemptive priority based RTOS, priority inversion problem is > > among the major sources of deadline violations. Priority inheritance > > protocol is one of the approaches to reduce priority inversion. > > As others have already said, the best way to avoid priority inheritance is > to not design it into your system in the first place. Having said that: > > > Unfortunately, RTOS like uC/OS can't support priority inheritance > > protocol since it does not allow kernel to have multiple tasks at the > > same priority. " > > As far as I know, this statement is just plain wrong.
How can you call that as wrong ? I think, that is True :( Kindly refer the Abstract present in the below link that has those lines - http://csdl2.computer.org/persagen/DLAbsToc.jsp?resourcePath=/dl/proceedings/&toc=comp/proceedings/wstfes/2003/1937/00/1937toc.xml&DOI=10.1109/WSTFES.2003.1201367 I think, It must be True :( !! Also, I Continued to explore some information based on this and i got some info - The below was got from this link -> http://archive.chipcenter.com/circuitcellar/november99/c119r15.htm " Also, earlier I mentioned that some RTOS vendors chose to ignore priority inversion while others implement priority inheritance algorithms to solve the problem. If you want more detailed information about the subject, here is an excellent paper to read: Sha, L., Rajkumar, R. and Sathaye, S.: Priority Inheritance Protocols: An Approach to Real-Time Synchronization. IEEE Transactions on Computers, Vol. 39(9). pp.1175-1185. "
> I don't know whether > uC/OS does or does not support priority inheritance, but I don't see why > only having one task at each priority would prevent its use, with some care. > > > Is it true that uC/OS does not support multiple tasks of same > > priority ? > > Yes it is true. Again, you are asking questions the answer to which you can > find out for yourself by reading the documentation. >
It has not been explicitly mentioned and hence i have approached the groups for help . It states that it supports Mututal exclusion semaphores (to reduce priority inversions) :):) I think, it is not possible as uCos does not appear to be a Real RTOS. It does not come under High End or even Mid Range RTOS. It is coming under Low End RTOS. Any other reasons / info ? Karthik Balaguru
On 2007-10-14, Paul Keinanen <keinanen@sci.fi> wrote:

>>Is it true that uC/OS does not support multiple tasks of same >>priority?
Yes.
>>Any specific reason for such a design of uC/OS kernel? > > When you have two or more tasks at the same priority level, > you usually would have to run some kind of round robin > scheduling between these.
That's often what is done, but it's not really required. You can just pick one of the tasks and run it until it blocks.
> In many simple kernels, the priority levels are fixed (e.g. > the order in which they were created at compile or startup > time), so the task list is always scanned in the same order > with a strict sequence and there is no way to boost > temporarily the priority of a single task (as needed by some > priority avoidance protocols).
uC/OS-II uses a bitmap scheduler. Each task is represented as a single bit in a set of bits. When a task is runnable the bit is set. The highest priority task is then simply the one corresponding to the most significant bit in the set. This mechanism is very fast and compact. However, it also means it isn't possible to have two tasks at the same priority. There's no technical reason why a task's priority can't be temporarily boosted when using a bitmap scheduler, it just can't be boosted to a priority level that's already in use.
> Some priority inversion avoidance system might be useful in > large systems with libraries form multiple vendors in which > you have no control what internal resources each library is > locking, but in small systems using some very simple RT > kernels, I really do not see any need for any priority > inversion avoidance protocol.
Agreed. -- Grant Edwards grante Yow! I'd like MY data-base at JULIENNED and stir-fried! visi.com
On 2007-10-14, Vladimir Vassilevsky <antispam_bogus@hotmail.com> wrote:
> > "karthikbalaguru" <karthikbalaguru79@gmail.com> wrote in message > news:1192346109.142121.40350@y27g2000pre.googlegroups.com... >> Hi, >> >> I got an interesting information from internet and i have some queries >> based on it as it is really strange/unbeleivable . >> >> " In a preemptive priority based RTOS, priority inversion problem is >> among the major sources of deadline violations. Priority inheritance >> protocol is one of the approaches to reduce priority inversion. >> Unfortunately, RTOS like uC/OS can't support priority inheritance >> protocol since it does not allow kernel to have multiple tasks at the >> same priority. " >> >> Is it true that uC/OS does not support multiple tasks of same >> priority ? >> Any specific reason for such a design of uC/OS kernel ? > > Mucos is a toy.
I call bullshit. It's a small, minimal RTOS.
> It is not a real OS, but a bare minimum.
If a bare minimum is all that's needed, only fool buys useless extras.
> For that reason it is lacking many useful services.
That depends on your definition of "useful". On my most recent project, I only found one feature that I would have liked to have had (binary semaphores), so I spend 10 minutes and added them. OTOH, try using VxWorks or the like with 48K of code space.
> The mucos core is basically the multi level interrupt > controller implemented in the software. Each thread is > assigned to the fixed priority level;
Nonsense.
> this concept simplifies a lot of things. However one can > implement the priority elevation mechanism in mucos by hand. > This is possible but slow and cumbersome.
-- Grant Edwards grante Yow! Awright, which one of at you hid my PENIS ENVY? visi.com
On 2007-10-14, FreeRTOS.org <noemal@address.com> wrote:

>> Unfortunately, RTOS like uC/OS can't support priority >> inheritance protocol since it does not allow kernel to have >> multiple tasks at the same priority. " > > As far as I know, this statement is just plain wrong. I don't > know whether uC/OS does or does not support priority > inheritance, but I don't see why only having one task at each > priority would prevent its use, with some care.
You would have to leave priority gaps between all of the user tasks so that there are empty priority slots into which you can elevate tasks temporarily. Other than that, I don't see why it couldn't be done. OTOH, uC/OS is typically used on fairly small projects where priority inversion can be avoided by design rather than worked-around at run-time.
>> Is it true that uC/OS does not support multiple tasks of same >> priority ? > > Yes it is true. Again, you are asking questions the answer to > which you can find out for yourself by reading the > documentation.
Isn't that what Usenet is all about? :) -- Grant Edwards grante Yow! LOOK!!! I'm WALKING at in my SLEEP again!! visi.com