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:
Gregory Nutt
2017-10-04 15:22:27 -06:00
parent 42a0796615
commit 9568600ab1
307 changed files with 3421 additions and 2423 deletions
+6 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/mmap/fs_munmap.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -120,10 +120,11 @@ int munmap(FAR void *start, size_t length)
/* Find a region containing this start and length in the list of regions */
rammap_initialize();
ret = sem_wait(&g_rammaps.exclsem);
ret = nxsem_wait(&g_rammaps.exclsem);
if (ret < 0)
{
return ERROR;
errcode = ret;
goto errout;
}
/* Seach the list of regions */
@@ -205,6 +206,8 @@ int munmap(FAR void *start, size_t length)
errout_with_semaphore:
nxsem_post(&g_rammaps.exclsem);
errout:
set_errno(errcode);
return ERROR;
}
+7 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/mmap/fs_rammmap.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -220,10 +220,11 @@ FAR void *rammap(int fd, size_t length, off_t offset)
/* Add the buffer to the list of regions */
rammap_initialize();
ret = sem_wait(&g_rammaps.exclsem);
ret = nxsem_wait(&g_rammaps.exclsem);
if (ret < 0)
{
goto errout_with_errno;
errcode = -ret;
goto errout_with_region;
}
map->flink = g_rammaps.head;
@@ -234,13 +235,16 @@ FAR void *rammap(int fd, size_t length, off_t offset)
errout_with_region:
kumm_free(alloc);
errout:
set_errno(errcode);
return MAP_FAILED;
#ifndef CONFIG_DEBUG_FS
errout_with_errno:
kumm_free(alloc);
return MAP_FAILED;
#endif
}
#endif /* CONFIG_FS_RAMMAP */