pkarashchenko commented on pull request #5070:
URL: https://github.com/apache/incubator-nuttx/pull/5070#issuecomment-1006118747


   > > Another real case: #5170, both case will generate hard fault.
   > 
   > I run ostest with https://github.com/apache/incubator-nuttx/pull/5171, no 
such assertions were found.
   > 
   > I think priority inheritance should only be valid for mutex, so there is 
only one holder per semphore at most.
   > 
   > The current implementation still cannot avoid priority flipping completely.
   > For example, there are 3 tasks t2 > t1 > t0, t0 held sem1, t1 held sem2 
and wait sem1, then t2 wait sem2. In this case, only t1's priority is raised.
   > If multiple holders are supported, this problem is very difficult to 
solve, which is the O(n^2) level.
   > 
   > If only one holder is supported, many things can be simplified.
   > 
   > 
   
   The semaphores are the building blocks for the pthread mutexes and here is 
some description for pthread mutexes:
   > When a thread makes a call to pthread_mutex_lock(), the mutex was 
initialized with the protocol attribute having the value PTHREAD_PRIO_INHERIT, 
when the calling thread is blocked because the mutex is owned by another 
thread, that owner thread shall inherit the priority level of the calling 
thread as long as it continues to own the mutex. The implementation shall 
update its execution priority to the maximum of its assigned priority and all 
its inherited priorities. Furthermore, if this owner thread itself becomes 
blocked on another mutex with the protocol attribute having the value 
PTHREAD_PRIO_INHERIT, the same priority inheritance effect shall be propagated 
to this other owner thread, in a recursive manner.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to