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: fatal error:set_priority()


ÕÅ ÁÁ <johnsonest@hotmail.com> writes:

> Dear nickg,
>             about changing a thread's priority in ecos,I have some
> different opinion:
>   ecos method:
>         remove  "this" thread from queue which the thread exists in
> ,then set new
> priority and add the thread into new ready queue or old quque.if need
> reschedule,
> set need_sched and unlock()
> 
>  questions:
>                1 if this thread 's state==RUNNING(  current thread or
> not current thread) and owned a mutex,and ecos set a lower
> priority,then,all thread waiting mutex were waiting long term
> undetermined!
>          2 if this thread 's state!=RUNNING but sleeping for a mutex,
> and ecos set a highest priority in its queue,why not  priority
> inherent occurs?
>          3not only mutex,but other critical resource:files,device,the
> same problem exists!
>   suggestion:
>          this topic is complex,
>         i think the function:set_priority() should be called with more
> limitations:
>           it should be called only for suspended thread,reset thread.

Well, I hardly think this is a fatal error.

Without a lot of extra mechanism to track mutex ownership it is not
easy to make this work perfectly. Adding such a mechanism would render
mutex locking and unlocking non-deterministic.

We really do not expect applications to be bouncing the priorities of
their threads around arbitrarily. Like thread termination, changing
priority is really something that a thread should do itself, when it
is in a safe state. In most applications, threads do not change their
priorities at all.

The documentation should probably have more explicit warnings about
when it is, and is not, safe to change thread priorities, and maybe we
should add some assertions to point out any potential misuses.

-- 
Nick Garnett - eCos Kernel Architect


--
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]