Revert "Assert if a thread attempts to post a semaphore incorrectly."
This reverts commit 758e88672b
.
This commit is contained in:
parent
6d4023809b
commit
2864e8c4b4
@ -28,7 +28,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <arch/irq.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "semaphore/semaphore.h"
|
#include "semaphore/semaphore.h"
|
||||||
@ -1059,62 +1058,4 @@ void nxsem_release_all(FAR struct tcb_s *htcb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: nxsem_isholder
|
|
||||||
*
|
|
||||||
* Assertion helper for sem_post(). If priority inheritance is enabled
|
|
||||||
* assure that the calling thread is the same as the holder thread.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_ASSERTIONS
|
|
||||||
bool nxsem_checkholder(FAR sem_t *sem)
|
|
||||||
{
|
|
||||||
FAR struct tcb_s *htcb;
|
|
||||||
pid_t tid;
|
|
||||||
|
|
||||||
/* Is priorty inheritance selected? */
|
|
||||||
|
|
||||||
if ((sem->flags & SEM_PRIO_MASK) != SEM_PRIO_INHERIT)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the thread ID. Skip thread ID 0; that is the IDLE thread which
|
|
||||||
* normally does not take semaphores but may do so initially as part of
|
|
||||||
* OS bringup.
|
|
||||||
*/
|
|
||||||
|
|
||||||
tid = gettid();
|
|
||||||
if (tid == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A semaphore with priority inheritance enabled cannot be called from an
|
|
||||||
* interrupt handler. There is no valid holder information available in
|
|
||||||
* the interrupt context.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (up_interrupt_context())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the TCB associated with this thread */
|
|
||||||
|
|
||||||
htcb = nxsched_get_tcb(tid);
|
|
||||||
if (htcb == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return FALSE is the thread of this TCB is not a holder of this
|
|
||||||
* semaphore.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return nxsem_findholder(sem, htcb) != NULL;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_DEBUG_ASSERTIONS */
|
|
||||||
|
|
||||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||||
|
@ -78,12 +78,6 @@ int nxsem_post(FAR sem_t *sem)
|
|||||||
|
|
||||||
DEBUGASSERT(sem != NULL);
|
DEBUGASSERT(sem != NULL);
|
||||||
|
|
||||||
/* If priority inheritance is enabled assure that the calling thread is
|
|
||||||
* the same as the holder thread.
|
|
||||||
*/
|
|
||||||
|
|
||||||
DEBUGASSERT(nxsem_checkholder(sem));
|
|
||||||
|
|
||||||
/* The following operations must be performed with interrupts
|
/* The following operations must be performed with interrupts
|
||||||
* disabled because sem_post() may be called from an interrupt
|
* disabled because sem_post() may be called from an interrupt
|
||||||
* handler.
|
* handler.
|
||||||
|
@ -91,12 +91,6 @@ void nxsem_release_all(FAR struct tcb_s *stcb);
|
|||||||
# define nxsem_release_all(stcb)
|
# define nxsem_release_all(stcb)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_ASSERTIONS) && defined(CONFIG_PRIORITY_INHERITANCE)
|
|
||||||
bool nxsem_checkholder(FAR sem_t *sem);
|
|
||||||
#else
|
|
||||||
# define nxsem_checkholder(sem) true
|
|
||||||
#endif /* CONFIG_DEBUG_ASSERTIONS */
|
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user