fjpanag commented on pull request #5266:
URL: https://github.com/apache/incubator-nuttx/pull/5266#issuecomment-1017817251


   > @fjpanag could you try this patch whether fix your problem.
   
   Sorry, too busy yesterday.  
   I just had the chance to test this on actual hardware.
   For the moment it seems that *at least on my application*, it resolves the 
issue.
   
   However I think that this is a bad solution, because it has the potential 
for an ugly deadlock.
   The other propositions harmed the real-time behavior of the system, but this 
can lock us outside of the mm!
   
   Since the priority of the Idle Task cannot be boosted anymore, and since it 
holds the mm, if it doesn't get the chance to run again then we lost access to 
the mm. And this chance seems quite high, because the Idle task mostly holds 
this semaphore and because it is normal for real-time systems to never return 
to idle.
   
   ---
   ```
   enter_crtitical_sectiion();
   mm_checkcurrption();
   leave_crtitical_sectiion();
   ```
   
   This solution is better, since it cannot cause this issue.  
   On the other hand, it locks the system unecessarily most of the time, causes 
heavy jitter and harms the RT behaviour.
   
   ---
   
   ```
   if ((sched_priority < SCHED_PRIORITY_MIN ||
       sched_priority > SCHED_PRIORITY_MAX) &&
       !(sched_priority == 0 && tcb->pid == 0))
     {
       return -EINVAL;
     }
   ```
   
   I believe that this is even better, because it has the disadvantages of the 
previous solution *only if it is actually needed*, not every time. It is still 
harmful though.
   
   ---
   
   At this moment I am of the strong belief that the Idle Task must do nothing 
at all.  
   Everything it does should be moved to workers or elsewhere. Somewhere that 
they can be properly managed, and affect the system in a logical and expected 
way.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to