mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +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:
@@ -502,7 +502,7 @@ static int i2c_slave_callback(FAR void *arg, i2c_slave_complete_t status,
|
|||||||
priv->read_index = 0;
|
priv->read_index = 0;
|
||||||
priv->read_length = length;
|
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);
|
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 */
|
/* 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);
|
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 */
|
/* 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);
|
nxsem_post(&priv->txsem);
|
||||||
}
|
}
|
||||||
while (nxsem_get_value(&priv->txsem, &semval) == 0 && semval <= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user