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:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/mmcsd/mmcsd_sdio.c
|
||||
*
|
||||
* Copyright (C) 2009-2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009-2013, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -279,18 +279,23 @@ static const struct block_operations g_bops =
|
||||
|
||||
static void mmcsd_takesem(FAR struct mmcsd_state_s *priv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Take the semaphore, giving exclusive access to the driver (perhaps
|
||||
* waiting)
|
||||
*/
|
||||
|
||||
while (sem_wait(&priv->sem) != 0)
|
||||
do
|
||||
{
|
||||
ret = nxsem_wait(&priv->sem);
|
||||
|
||||
/* The only case that an error should occur here is if the wait was
|
||||
* awakened by a signal.
|
||||
*/
|
||||
|
||||
ASSERT(errno == EINTR);
|
||||
DEBUGASSERT(ret == OK || ret == -EINTR);
|
||||
}
|
||||
while (ret == -EINTR);
|
||||
|
||||
/* Lock the bus if mutually exclusive access to the SDIO bus is required
|
||||
* on this platform.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/mmcsd/mmcsd_spi.c
|
||||
*
|
||||
* Copyright (C) 2008-2010, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008-2010, 2011-2013, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -354,6 +354,8 @@ static const struct mmcsd_cmdinfo_s g_acmd41 = {ACMD41, MMCSD_CMDRESP_R1, 0xff};
|
||||
|
||||
static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Get exclusive access to the SPI bus (if necessary) */
|
||||
|
||||
(void)SPI_LOCK(slot->spi, true);
|
||||
@@ -371,14 +373,19 @@ static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot)
|
||||
* SPI_LOCK is also implemented as a semaphore).
|
||||
*/
|
||||
|
||||
while (sem_wait(&slot->sem) != 0)
|
||||
do
|
||||
{
|
||||
/* Take the semaphore (perhaps waiting) */
|
||||
|
||||
ret = nxsem_wait(&slot->sem);
|
||||
|
||||
/* The only case that an error should occur here is if the wait was
|
||||
* awakened by a signal.
|
||||
*/
|
||||
|
||||
ASSERT(errno == EINTR);
|
||||
DEBUGASSERT(ret == OK || ret == -EINTR);
|
||||
}
|
||||
while (ret == -EINTR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user