sched/semaphore: Always free mutex holder at nxsem_post
There is no need to check the holder structure "counts". There are cases where the counts may be greater than 1 when several tasks block on the mutex, but there is always just one holder, which must be freed. Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This commit is contained in:
parent
f3231a1934
commit
b2315e98c4
1 changed files with 6 additions and 2 deletions
|
|
@ -240,9 +240,11 @@ static int nxsem_freecount0holder(FAR struct semholder_s *pholder,
|
|||
{
|
||||
/* When no more counts are held, remove the holder from the list. The
|
||||
* count was decremented in nxsem_release_holder.
|
||||
*
|
||||
* Mutex is held only by one thread, so the holder is always freed.
|
||||
*/
|
||||
|
||||
if (pholder->counts <= 0)
|
||||
if (pholder->counts <= 0 || NXSEM_IS_MUTEX(sem))
|
||||
{
|
||||
nxsem_freeholder(sem, pholder);
|
||||
return 1;
|
||||
|
|
@ -442,9 +444,11 @@ static int nxsem_restoreholderprio(FAR struct semholder_s *pholder,
|
|||
|
||||
/* Release the holder if all counts have been given up
|
||||
* before reprioritizing causes a context switch.
|
||||
*
|
||||
* Mutex is held only by one thread, so the holder is always freed.
|
||||
*/
|
||||
|
||||
if (pholder->counts <= 0)
|
||||
if (pholder->counts <= 0 || NXSEM_IS_MUTEX(sem))
|
||||
{
|
||||
nxsem_freeholder(sem, pholder);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue