mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 02:48:37 +08:00
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:
parent
c86f4d66da
commit
a5aea61537
3 changed files with 3 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
Loading…
Reference in a new issue