mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 06:42:32 +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 @@
|
||||
/****************************************************************************
|
||||
* mm/iob/iob_alloc_qentry.c
|
||||
*
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -130,11 +130,9 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
|
||||
* semaphore count will be incremented.
|
||||
*/
|
||||
|
||||
ret = sem_wait(&g_qentry_sem);
|
||||
ret = nxsem_wait(&g_qentry_sem);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
|
||||
/* EINTR is not an error! EINTR simply means that we were
|
||||
* awakened by a signal and we should try again.
|
||||
*
|
||||
@@ -144,20 +142,11 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
|
||||
* the error should be returned.
|
||||
*/
|
||||
|
||||
if (errcode == EINTR)
|
||||
if (ret == -EINTR)
|
||||
{
|
||||
/* Force a success indication so that we will continue
|
||||
* looping.
|
||||
*/
|
||||
/* Force a success indication so that we will continue looping. */
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Stop the loop and return a error */
|
||||
|
||||
DEBUGASSERT(errcode > 0);
|
||||
ret = -errcode;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -256,7 +245,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
|
||||
g_iob_freeqlist = iobq->qe_flink;
|
||||
|
||||
/* Take a semaphore count. Note that we cannot do this in
|
||||
* in the orthodox way by calling sem_wait() or sem_trywait()
|
||||
* in the orthodox way by calling nxsem_wait() or sem_trywait()
|
||||
* because this function may be called from an interrupt
|
||||
* handler. Fortunately we know at at least one free buffer
|
||||
* so a simple decrement is all that is needed.
|
||||
|
||||
Reference in New Issue
Block a user