1
0
Fork 0
forked from nuttx/nuttx-update

driver: Post sempahore only when it's value is smaller than one

to avoid waking up the waiting thread redundantly.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-04-21 23:47:54 +08:00 committed by Xiang Xiao
parent c86f4d66da
commit a5aea61537
3 changed files with 3 additions and 5 deletions

View file

@ -502,7 +502,7 @@ static int i2c_slave_callback(FAR void *arg, i2c_slave_complete_t status,
priv->read_index = 0;
priv->read_length = length;
while (nxsem_get_value(&priv->wait, &semcount) >= 0 && semcount <= 1)
while (nxsem_get_value(&priv->wait, &semcount) >= 0 && semcount <= 0)
{
nxsem_post(&priv->wait);
}

View file

@ -90,11 +90,10 @@ void ipcc_rxfree_notify(FAR struct ipcc_driver_s *priv)
/* Notify all blocked readers that data is available to read */
do
while (nxsem_get_value(&priv->rxsem, &semval) >= 0 && semval <= 0)
{
nxsem_post(&priv->rxsem);
}
while (nxsem_get_value(&priv->rxsem, &semval) == 0 && semval <= 0);
}
/****************************************************************************

View file

@ -90,11 +90,10 @@ void ipcc_txfree_notify(FAR struct ipcc_driver_s *priv)
/* Notify all blocked writers that data is available to write */
do
while (nxsem_get_value(&priv->txsem, &semval) >= 0 && semval <= 0)
{
nxsem_post(&priv->txsem);
}
while (nxsem_get_value(&priv->txsem, &semval) == 0 && semval <= 0);
}
/****************************************************************************