This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: some issues relating to current_thread


Brij Bihari Pandey <fuzzhead012@yahoo.com> writes:

> Thanks Nick for the reply,
> 
> > I did look closely at implementing mutexes with a
> > spinlock or a
> > compare-and-swap mechanism. While this could be made
> > to work for
> > uncontended mutexes that do not implement any
> > priority inversion
> > protocol, it does not work for protected mutexes.
> Another naive doubt, what do you mean by protected
> Mutex? How many different classifications of mutex we
> have in eCos? any appropriate link is welcome.

By protected I simply mean a mutex that protects itself against
priority inversion by implementing one of the protocols. Mutexes may
implement priority inheritance protocol, priority ceiling protocol or
no protocol at all. They can be configured to implement one protocol
statically or to allow the application to choose dynamically at run
time.

> 
> > It is much more
> > important for real time performace to handle
> > priority inversion correctly
> Can you please explain why spinlock protection
> mechanism will not work with priority inversion
> correctly? May be, you can give some hints into eCos
> sections where I can look to understand what you have
> mentioned.
> 

To operate either of the priority inversion protocols correctly, the
thread must access not only the mutex but also its own thread object
and, if the priority is to be changed, the scheduler too. For priority
inheritance the thread objects of other threads may also need to be
accessed. So a thread has to take the scheduler lock anyway. The only
situation where a thread could get away with only using a spinlock on
the mutex is when the mutex implements no priority inversion protocol
and there is no other thread contending for access.

Take a look at the mutex implementation for details -- although it is
a bit messy due to all the configuration options supported.

-- 
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]