mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Squashed commit of the following:
This commit backs out most of commit b4747286b1. That change was added because sem_wait() would sometimes cause cancellation points inappropriated. But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.
In the OS, all calls to sem_wait() changed to nxsem_wait(). nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.
In all OS functions (not libraries), change sem_wait() to nxsem_wait(). This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.
sched/semaphore: Add the function nxsem_wait(). This is a new internal OS interface. It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
This commit is contained in:
@@ -173,14 +173,14 @@ static ssize_t xen1210_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
/* Get exclusive access to the driver data structure */
|
||||
|
||||
ret = sem_wait(&priv->exclsem);
|
||||
ret = nxsem_wait(&priv->exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* This should only happen if the wait was canceled by an signal */
|
||||
|
||||
snerr("Failed: Cannot get exclusive access to driver structure!\n");
|
||||
DEBUGASSERT(errno == EINTR);
|
||||
return -EINTR;
|
||||
DEBUGASSERT(ret == -EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sninfo("X = 0x%06X\n", priv->sample.data_x);
|
||||
@@ -374,12 +374,11 @@ int xen1210_register(XEN1210_HANDLE handle, int minor)
|
||||
|
||||
/* Get exclusive access to the device structure */
|
||||
|
||||
ret = sem_wait(&priv->exclsem);
|
||||
ret = nxsem_wait(&priv->exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errval = errno;
|
||||
snerr("ERROR: sem_wait failed: %d\n", errval);
|
||||
return -errval;
|
||||
snerr("ERROR: nxsem_wait failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Register the character driver */
|
||||
|
||||
Reference in New Issue
Block a user