mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 19:03:35 +08:00
Add some protection to the priority inheritance logic when sem_post() is called from an interrupt handler
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5060 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+10
-6
@@ -123,17 +123,21 @@ int sem_post(FAR sem_t *sem)
|
||||
sem_releaseholder(sem);
|
||||
sem->semcount++;
|
||||
|
||||
/* If the result of of semaphore unlock is non-positive, then
|
||||
* there must be some task waiting for the semaphore.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
/* Don't let it run until we complete the priority restoration
|
||||
* steps.
|
||||
/* Don't let any unblocked tasks run until we complete any priority
|
||||
* restoration steps. Interrupts are disabled, but we do not want
|
||||
* the head of the read-to-run list to be modified yet.
|
||||
*
|
||||
* NOTE: If this sched_lock is called from an interrupt handler, it
|
||||
* will do nothing.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
#endif
|
||||
/* If the result of of semaphore unlock is non-positive, then
|
||||
* there must be some task waiting for the semaphore.
|
||||
*/
|
||||
|
||||
if (sem->semcount <= 0)
|
||||
{
|
||||
/* Check if there are any tasks in the waiting for semaphore
|
||||
|
||||
Reference in New Issue
Block a user