diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-31 01:42:50 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-31 01:42:50 +0000 |
commit | fd57b2a0da0473e878eb1c2abef05de3be7c2e2d (patch) | |
tree | 942c9e6714349eb61faa27c17a71cf2c689cb65a /nuttx/sched | |
parent | 2d6e5ff6c4450662ffc8d1d8d2f46da0155d6905 (diff) | |
download | px4-nuttx-fd57b2a0da0473e878eb1c2abef05de3be7c2e2d.tar.gz px4-nuttx-fd57b2a0da0473e878eb1c2abef05de3be7c2e2d.tar.bz2 px4-nuttx-fd57b2a0da0473e878eb1c2abef05de3be7c2e2d.zip |
Move more files into subdirectories under lib/
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3445 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
28 files changed, 12 insertions, 2692 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index 50ef997fc..ab83a8fee 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -100,22 +100,12 @@ ifneq ($(CONFIG_DISABLE_SIGNALS),y) MQUEUE_SRCS += mq_notify.c endif -PTHREAD_SRCS = pthread_attrinit.c pthread_attrdestroy.c \ - pthread_attrsetschedpolicy.c pthread_attrgetschedpolicy.c \ - pthread_attrsetinheritsched.c pthread_attrgetinheritsched.c \ - pthread_attrsetstacksize.c pthread_attrgetstacksize.c \ - pthread_attrsetschedparam.c pthread_attrgetschedparam.c \ - pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \ +PTHREAD_SRCS = pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \ pthread_yield.c pthread_getschedparam.c pthread_setschedparam.c \ - pthread_mutexattrinit.c pthread_mutexattrdestroy.c \ - pthread_mutexattrgetpshared.c pthread_mutexattrsetpshared.c \ pthread_mutexinit.c pthread_mutexdestroy.c \ pthread_mutexlock.c pthread_mutextrylock.c pthread_mutexunlock.c \ pthread_condinit.c pthread_conddestroy.c \ - pthread_condattrinit.c pthread_condattrdestroy.c \ pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c \ - pthread_barrierattrinit.c pthread_barrierattrdestroy.c \ - pthread_barrierattrgetpshared.c pthread_barrierattrsetpshared.c \ pthread_barrierinit.c pthread_barrierdestroy.c pthread_barrierwait.c \ pthread_cancel.c pthread_setcancelstate.c \ pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c pthread_keydelete.c \ @@ -124,14 +114,9 @@ PTHREAD_SRCS = pthread_attrinit.c pthread_attrdestroy.c \ ifneq ($(CONFIG_DISABLE_SIGNALS),y) PTHREAD_SRCS += pthread_condtimedwait.c pthread_kill.c pthread_sigmask.c endif -ifeq ($(CONFIG_MUTEX_TYPES),y) -PTHREAD_SRCS += pthread_mutexattrsettype.c pthread_mutexattrgettype.c -endif -SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\ - sem_open.c sem_close.c sem_unlink.c \ - sem_wait.c sem_trywait.c sem_post.c sem_getvalue.c \ - sem_findnamed.c +SEM_SRCS = sem_initialize.c sem_open.c sem_close.c sem_unlink.c \ + sem_wait.c sem_trywait.c sem_post.c sem_findnamed.c ifneq ($(CONFIG_DISABLE_SIGNALS),y) SEM_SRCS += sem_waitirq.c endif diff --git a/nuttx/sched/pthread_attrdestroy.c b/nuttx/sched/pthread_attrdestroy.c deleted file mode 100644 index bfa1a49a9..000000000 --- a/nuttx/sched/pthread_attrdestroy.c +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrdestroy.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_destroy - * - * Description: - * An attributes object can be deleted when it is no longer - * needed. - * - * Parameters: - * attr - * - * Return Value: - * 0 meaning success - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_destroy(FAR pthread_attr_t *attr) -{ - int ret; - - sdbg("attr=0x%p\n", attr); - - if (!attr) - { - ret = EINVAL; - } - else - { - memset(attr, 0, sizeof(pthread_attr_t)); - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - diff --git a/nuttx/sched/pthread_attrgetinheritsched.c b/nuttx/sched/pthread_attrgetinheritsched.c deleted file mode 100644 index 7accfcdf7..000000000 --- a/nuttx/sched/pthread_attrgetinheritsched.c +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrgetinheritsched.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_getinheritsched - * - * Description: - * Report whether the scheduling info in the pthread - * attributes will be used or if the thread will - * inherit the properties of the parent. - * - * Parameters: - * attr - * inheritsched - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr, - FAR int *inheritsched) -{ - int ret; - - sdbg("attr=0x%p inheritsched=0x%p\n", attr, inheritsched); - - if (!attr || !inheritsched) - { - ret = EINVAL; - } - else - { - *inheritsched = (int)attr->inheritsched; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - diff --git a/nuttx/sched/pthread_attrgetschedparam.c b/nuttx/sched/pthread_attrgetschedparam.c deleted file mode 100644 index 513a941a3..000000000 --- a/nuttx/sched/pthread_attrgetschedparam.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrgetschedparam.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <sched.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_getschedparam - * - * Description: - * - * Parameters: - * attr - * param - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_getschedparam(FAR pthread_attr_t *attr, - FAR struct sched_param *param) -{ - int ret; - - sdbg("attr=0x%p param=0x%p\n", attr, param); - - if (!attr || !param) - { - ret = EINVAL; - } - else - { - param->sched_priority = attr->priority; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - - diff --git a/nuttx/sched/pthread_attrgetschedpolicy.c b/nuttx/sched/pthread_attrgetschedpolicy.c deleted file mode 100644 index de72ef8d6..000000000 --- a/nuttx/sched/pthread_attrgetschedpolicy.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * pthread_attrgetschedpolicy.c - * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <sys/types.h> -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_getschedpolicy - * - * Description: - * Obtain the scheduling algorithm attribute. - * - * Parameters: - * attr - * policy - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_getschedpolicy(FAR pthread_attr_t *attr, int *policy) -{ - int ret; - - sdbg("attr=0x%p policy=0x%p\n", attr, policy); - - if (!attr || !policy) - { - ret = EINVAL; - } - else - { - *policy = attr->policy; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_attrgetstacksize.c b/nuttx/sched/pthread_attrgetstacksize.c deleted file mode 100644 index 82c15004b..000000000 --- a/nuttx/sched/pthread_attrgetstacksize.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrgetstacksize.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <sys/types.h> -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_getstacksize - * - * Description: - * - * Parameters: - * attr - * stacksize - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_getstacksize(FAR pthread_attr_t *attr, FAR long *stacksize) -{ - int ret; - - sdbg("attr=0x%p stacksize=0x%p\n", attr, stacksize); - - if (!stacksize) - { - ret = EINVAL; - } - else - { - *stacksize = attr->stacksize; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - diff --git a/nuttx/sched/pthread_attrinit.c b/nuttx/sched/pthread_attrinit.c deleted file mode 100644 index ed260aa83..000000000 --- a/nuttx/sched/pthread_attrinit.c +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrinit.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_init - * - * Description: - * Initializes a thread attributes object (attr) with - * default values for all of the individual attributes - * used by a given implementation. - * - * Parameters: - * attr - * - * Return Value: - * 0 on success, otherwise an error number - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_init(FAR pthread_attr_t *attr) -{ - int ret = OK; - - sdbg("attr=0x%p\n", attr); - if (!attr) - { - ret = ENOMEM; - } - else - { - /* Set the child thread priority to be the default - * priority. Set the child stack size to some arbitrary - * default value. - */ - - memcpy(attr, &g_default_pthread_attr, sizeof(pthread_attr_t)); - } - - sdbg("Returning %d\n", ret); - return ret; -} - diff --git a/nuttx/sched/pthread_attrsetinheritsched.c b/nuttx/sched/pthread_attrsetinheritsched.c deleted file mode 100644 index 9b0e6ac80..000000000 --- a/nuttx/sched/pthread_attrsetinheritsched.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrsetinheritsched.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_setinheritsched - * - * Description: - * Indicate whether the scheduling info in the pthread - * attributes will be used or if the thread will - * inherit the properties of the parent. - * - * Parameters: - * attr - * policy - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_setinheritsched(FAR pthread_attr_t *attr, - int inheritsched) -{ - int ret; - - sdbg("inheritsched=%d\n", inheritsched); - - if (!attr || - (inheritsched != PTHREAD_INHERIT_SCHED && - inheritsched != PTHREAD_EXPLICIT_SCHED)) - { - ret = EINVAL; - } - else - { - attr->inheritsched = (uint8_t)inheritsched; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - diff --git a/nuttx/sched/pthread_attrsetschedparam.c b/nuttx/sched/pthread_attrsetschedparam.c deleted file mode 100644 index cd806d72f..000000000 --- a/nuttx/sched/pthread_attrsetschedparam.c +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrsetschedparam.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <sched.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_setschedparam - * - * Description: - * - * Parameters: - * attr - * param - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_setschedparam(FAR pthread_attr_t *attr, - FAR const struct sched_param *param) -{ - int ret; - - sdbg("attr=0x%p param=0x%p\n", attr, param); - - if (!attr || !param) - { - ret = EINVAL; - } - else - { - attr->priority = (short)param->sched_priority; - ret = OK; - } - sdbg("Returning %d\n", ret); - return ret; -} - - diff --git a/nuttx/sched/pthread_attrsetschedpolicy.c b/nuttx/sched/pthread_attrsetschedpolicy.c deleted file mode 100644 index 93756f070..000000000 --- a/nuttx/sched/pthread_attrsetschedpolicy.c +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrsetschedpolicy.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <sched.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_setschedpolicy - * - * Description: - * Set the scheduling algorithm attribute. - * - * Parameters: - * attr - * policy - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy) -{ - int ret; - - sdbg("attr=0x%p policy=%d\n", attr, policy); - -#if CONFIG_RR_INTERVAL > 0 - if (!attr || (policy != SCHED_FIFO && policy != SCHED_RR)) -#else - if (!attr || policy != SCHED_FIFO ) -#endif - { - ret = EINVAL; - } - else - { - attr->policy = policy; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_attrsetstacksize.c b/nuttx/sched/pthread_attrsetstacksize.c deleted file mode 100644 index 659a35d47..000000000 --- a/nuttx/sched/pthread_attrsetstacksize.c +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * sched/pthread_attrsetstacksize.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <string.h> -#include <debug.h> -#include <errno.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_attr_setstacksize - * - * Description: - * - * Parameters: - * attr - * stacksize - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize) -{ - int ret; - - sdbg("attr=0x%p stacksize=%ld\n", attr, stacksize); - - if (!attr || stacksize < PTHREAD_STACK_MIN) - { - ret = EINVAL; - } - else - { - attr->stacksize = stacksize; - ret = OK; - } - - sdbg("Returning %d\n", ret); - return ret; -} - diff --git a/nuttx/sched/pthread_barrierattrdestroy.c b/nuttx/sched/pthread_barrierattrdestroy.c deleted file mode 100644 index 813e95d8a..000000000 --- a/nuttx/sched/pthread_barrierattrdestroy.c +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************** - * sched/pthread_barrierattrdestroy.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ********************************************************************************/ - -/******************************************************************************** - * Included Files - ********************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -/******************************************************************************** - * Definitions - ********************************************************************************/ - -/******************************************************************************** - * Private Type Declarations - ********************************************************************************/ - -/******************************************************************************** - * Global Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Function Prototypes - ********************************************************************************/ - -/******************************************************************************** - * Public Functions - ********************************************************************************/ - -/******************************************************************************** - * Function: pthread_barrierattr_destroy - * - * Description: - * The pthread_barrierattr_destroy() function will destroy a barrier attributes - * object. A destroyed attr attributes object can be reinitialized using - * pthread_barrierattr_init(); the results of otherwise referencing the object - * after it has been destroyed are undefined. - * - * Parameters: - * attr - barrier attributes to be destroyed. - * - * Return Value: - * 0 (OK) on success or EINVAL if attr is invalid. - * - * Assumptions: - * - ********************************************************************************/ - -int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr) -{ - int ret = OK; - - if (!attr) - { - ret = EINVAL; - } - else - { - attr->pshared = PTHREAD_PROCESS_PRIVATE; - } - return ret; -} diff --git a/nuttx/sched/pthread_barrierattrgetpshared.c b/nuttx/sched/pthread_barrierattrgetpshared.c deleted file mode 100644 index 0e2cf30df..000000000 --- a/nuttx/sched/pthread_barrierattrgetpshared.c +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************** - * sched/pthread_barrierattrgetpshared.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ********************************************************************************/ - -/******************************************************************************** - * Included Files - ********************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -/******************************************************************************** - * Definitions - ********************************************************************************/ - -/******************************************************************************** - * Private Type Declarations - ********************************************************************************/ - -/******************************************************************************** - * Global Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Function Prototypes - ********************************************************************************/ - -/******************************************************************************** - * Public Functions - ********************************************************************************/ - -/******************************************************************************** - * Function: pthread_barrierattr_getpshared - * - * Description: - * The pthread_barrierattr_getpshared() function will obtain the value of the - * process-shared attribute from the attributes object referenced by attr. - * - * Parameters: - * attr - barrier attributes to be queried. - * pshared - the location to stored the current value of the pshared attribute. - * - * Return Value: - * 0 (OK) on success or EINVAL if either attr or pshared is invalid. - * - * Assumptions: - * - ********************************************************************************/ - -int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared) -{ - int ret = OK; - - if (!attr || !pshared) - { - ret = EINVAL; - } - else - { - *pshared = attr->pshared; - } - return ret; -} diff --git a/nuttx/sched/pthread_barrierattrinit.c b/nuttx/sched/pthread_barrierattrinit.c deleted file mode 100644 index 3a0d346f1..000000000 --- a/nuttx/sched/pthread_barrierattrinit.c +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************** - * sched/pthread_barrierattrinit.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ********************************************************************************/ - -/******************************************************************************** - * Included Files - ********************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -/******************************************************************************** - * Definitions - ********************************************************************************/ - -/******************************************************************************** - * Private Type Declarations - ********************************************************************************/ - -/******************************************************************************** - * Global Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Function Prototypes - ********************************************************************************/ - -/******************************************************************************** - * Public Functions - ********************************************************************************/ - -/******************************************************************************** - * Function: pthread_barrierattr_init - * - * Description: - * The pthread_barrierattr_init() function will initialize a barrier attribute - * object attr with the default value for all of the attributes defined by the - * implementation. - * - * Parameters: - * attr - barrier attributes to be initialized. - * - * Return Value: - * 0 (OK) on success or EINVAL if attr is invalid. - * - * Assumptions: - * - ********************************************************************************/ - -int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr) -{ - int ret = OK; - - if (!attr) - { - ret = EINVAL; - } - else - { - attr->pshared = PTHREAD_PROCESS_PRIVATE; - } - return ret; -} diff --git a/nuttx/sched/pthread_barrierattrsetpshared.c b/nuttx/sched/pthread_barrierattrsetpshared.c deleted file mode 100644 index b13075791..000000000 --- a/nuttx/sched/pthread_barrierattrsetpshared.c +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************** - * sched/pthread_barrierattrsetpshared.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ********************************************************************************/ - -/******************************************************************************** - * Included Files - ********************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -/******************************************************************************** - * Definitions - ********************************************************************************/ - -/******************************************************************************** - * Private Type Declarations - ********************************************************************************/ - -/******************************************************************************** - * Global Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Variables - ********************************************************************************/ - -/******************************************************************************** - * Private Function Prototypes - ********************************************************************************/ - -/******************************************************************************** - * Public Functions - ********************************************************************************/ - -/******************************************************************************** - * Function: pthread_barrierattr_setpshared - * - * Description: - * The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit a - * barrier to be operated upon by any thread that has access to the memory where - * the barrier is allocated. If the process-shared attribute is - * PTHREAD_PROCESS_PRIVATE, the barrier can only be operated upon by threads - * created within the same process as the thread that initialized the barrier. - * If threads of different processes attempt to operate on such a barrier, the - * behavior is undefined. The default value of the attribute is - * PTHREAD_PROCESS_PRIVATE. - * - * Both constants PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE are defined - * in pthread.h. - * - * Parameters: - * attr - barrier attributes to be modified. - * pshared - the new value of the pshared attribute. - * - * Return Value: - * 0 (OK) on success or EINVAL if either attr is invalid or pshared is not one - * of PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE. - * - * Assumptions: - * - ********************************************************************************/ - -int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared) -{ - int ret = OK; - - if (!attr || (pshared != PTHREAD_PROCESS_SHARED && pshared != PTHREAD_PROCESS_PRIVATE)) - { - ret = EINVAL; - } - else - { - attr->pshared = pshared; - } - return ret; -} diff --git a/nuttx/sched/pthread_condattrdestroy.c b/nuttx/sched/pthread_condattrdestroy.c deleted file mode 100644 index 99e261ce2..000000000 --- a/nuttx/sched/pthread_condattrdestroy.c +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - * sched/pthread_condattrdestroy.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Global Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_condattr_destroy - * - * Description: - * Operations on condition variable attributes - * - * Parameters: - * None - * - * Return Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_condattr_destroy(FAR pthread_condattr_t *attr) -{ - int ret = OK; - - sdbg("attr=0x%p\n", attr); - - if (!attr) - { - ret = EINVAL; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - - diff --git a/nuttx/sched/pthread_condattrinit.c b/nuttx/sched/pthread_condattrinit.c deleted file mode 100644 index 30e3f71ac..000000000 --- a/nuttx/sched/pthread_condattrinit.c +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * sched/pthread_condattrinit.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <debug.h> -#include <errno.h> -#include "pthread_internal.h" - -/**************************************************************************** - * Global Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_condattr_init - * - * Description: - * Operations on condition variable attributes - * - * Parameters: - * None - * - * Return Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_condattr_init(FAR pthread_condattr_t *attr) -{ - int ret = OK; - - sdbg("attr=0x%p\n", attr); - - if (!attr) - { - ret = EINVAL; - } - else - { - *attr = 0; - } - - sdbg("Returning %d\n", ret); - return ret; -} - - diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c index b49698122..bedb7d3ba 100644 --- a/nuttx/sched/pthread_create.c +++ b/nuttx/sched/pthread_create.c @@ -47,7 +47,9 @@ #include <debug.h> #include <errno.h> #include <queue.h> + #include <nuttx/kmalloc.h> +#include <nuttx/pthread.h> #include <nuttx/arch.h> #include "os_internal.h" @@ -69,13 +71,7 @@ /* Default pthread attributes */ -FAR pthread_attr_t g_default_pthread_attr = -{ - PTHREAD_STACK_DEFAULT, /* stacksize */ - PTHREAD_DEFAULT_PRIORITY, /* priority */ - SCHED_RR, /* policy */ - PTHREAD_EXPLICIT_SCHED, /* inheritsched */ -}; +pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER; /**************************************************************************** * Private Variables diff --git a/nuttx/sched/pthread_internal.h b/nuttx/sched/pthread_internal.h index 1770ff1b5..6d8961e37 100644 --- a/nuttx/sched/pthread_internal.h +++ b/nuttx/sched/pthread_internal.h @@ -1,7 +1,7 @@ /**************************************************************************** - * pthread_internal.h + * sched/pthread_internal.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __PTHREAD_INTERNAL_H -#define __PTHREAD_INTERNAL_H +#ifndef __SCHED_PTHREAD_INTERNAL_H +#define __SCHED_PTHREAD_INTERNAL_H /**************************************************************************** * Included Files @@ -46,6 +46,7 @@ #include <stdint.h> #include <stdbool.h> #include <pthread.h> + #include <nuttx/compiler.h> /**************************************************************************** @@ -103,10 +104,6 @@ extern sem_t g_join_semaphore; extern uint8_t g_pthread_num_keys; -/* Default pthread attributes */ - -extern FAR pthread_attr_t g_default_pthread_attr; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -135,5 +132,5 @@ EXTERN int pthread_mutexattr_verifytype(int type); } #endif -#endif /* __PTHREAD_INTERNAL_H */ +#endif /* __SCHED_PTHREAD_INTERNAL_H */ diff --git a/nuttx/sched/pthread_mutexattrdestroy.c b/nuttx/sched/pthread_mutexattrdestroy.c deleted file mode 100644 index 64e6bbd75..000000000 --- a/nuttx/sched/pthread_mutexattrdestroy.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * sched/pthread_mutexattrdestroy.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_destroy - * - * Description: - * Destroy mutex attributes. - * - * Parameters: - * attr - * pshared - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_destroy(FAR pthread_mutexattr_t *attr) -{ - int ret = OK; - - sdbg("attr=0x%p\n", attr); - - if (!attr) - { - ret = EINVAL; - } - else - { - attr->pshared = 0; - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_mutexattrgetpshared.c b/nuttx/sched/pthread_mutexattrgetpshared.c deleted file mode 100644 index a70417cee..000000000 --- a/nuttx/sched/pthread_mutexattrgetpshared.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * sched/pthread_mutexattrgetpshared.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_getpshared - * - * Description: - * Get pshared mutex attribute. - * - * Parameters: - * attr - * pshared - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_getpshared(FAR pthread_mutexattr_t *attr, FAR int *pshared) -{ - int ret = OK; - - sdbg("attr=0x%p pshared=0x%p\n", attr, pshared); - - if (!attr || !pshared) - { - ret = EINVAL; - } - else - { - *pshared = attr->pshared; - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_mutexattrgettype.c b/nuttx/sched/pthread_mutexattrgettype.c deleted file mode 100644 index fb01c2383..000000000 --- a/nuttx/sched/pthread_mutexattrgettype.c +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - * sched/pthread_mutexattrgettype.c - * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <pthread.h> -#include <errno.h> - -#include "pthread_internal.h" - -#ifdef CONFIG_MUTEX_TYPES - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_gettype - * - * Description: - * Return the mutex type from the mutex attributes. - * - * Parameters: - * attr - The mutex attributes to query - * type - Location to return the mutex type - * - * Return Value: - * 0, if the mutex type was successfully return in 'type', or - * EINVAL, if any NULL pointers provided. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) -{ - if (attr && type) - { - *type = attr->type; - return 0; - } - return EINVAL; -} - -#endif /* CONFIG_MUTEX_TYPES */ diff --git a/nuttx/sched/pthread_mutexattrinit.c b/nuttx/sched/pthread_mutexattrinit.c deleted file mode 100644 index 6d155d4ca..000000000 --- a/nuttx/sched/pthread_mutexattrinit.c +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * pthread_mutexattrinit.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_init - * - * Description: - * Create mutex attributes. - * - * Parameters: - * attr - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_init(FAR pthread_mutexattr_t *attr) -{ - int ret = OK; - - sdbg("attr=0x%p\n", attr); - - if (!attr) - { - ret = EINVAL; - } - else - { - attr->pshared = 0; -#ifdef CONFIG_MUTEX_TYPES - attr->type = PTHREAD_MUTEX_DEFAULT; -#endif - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_mutexattrsetpshared.c b/nuttx/sched/pthread_mutexattrsetpshared.c deleted file mode 100644 index 22b70e118..000000000 --- a/nuttx/sched/pthread_mutexattrsetpshared.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * sched/pthread_mutexattrsetpshared.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <pthread.h> -#include <errno.h> -#include <debug.h> - -#include "pthread_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_setpshared - * - * Description: - * Set pshared mutex attribute. - * - * Parameters: - * attr - * pshared - * - * Return Value: - * 0 if successful. Otherwise, an error code. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_setpshared(FAR pthread_mutexattr_t *attr, int pshared) -{ - int ret = OK; - - sdbg("attr=0x%p pshared=%d\n", attr, pshared); - - if (!attr || (pshared != 0 && pshared != 1)) - { - ret = EINVAL; - } - else - { - attr->pshared = pshared; - } - - sdbg("Returning %d\n", ret); - return ret; -} diff --git a/nuttx/sched/pthread_mutexattrsettype.c b/nuttx/sched/pthread_mutexattrsettype.c deleted file mode 100644 index 0df24fda8..000000000 --- a/nuttx/sched/pthread_mutexattrsettype.c +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - * sched/pthread_mutexattrsettype.c - * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <pthread.h> -#include <errno.h> - -#include "pthread_internal.h" - -#ifdef CONFIG_MUTEX_TYPES - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: pthread_mutexattr_settype - * - * Description: - * Set the mutex type in the mutex attributes. - * - * Parameters: - * attr - The mutex attributes in which to set the mutex type. - * type - The mutex type value to set. - * - * Return Value: - * 0, if the mutex type was successfully set in 'attr', or - * EINVAL, if 'attr' is NULL or 'type' unrecognized. - * - * Assumptions: - * - ****************************************************************************/ - -int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) -{ - if (attr && type >= PTHREAD_MUTEX_NORMAL && type <= PTHREAD_MUTEX_RECURSIVE) - { - attr->type = type; - return OK; - } - return EINVAL; -} - -#endif /* CONFIG_MUTEX_TYPES */ diff --git a/nuttx/sched/sem_destroy.c b/nuttx/sched/sem_destroy.c deleted file mode 100644 index a0a7ca3d1..000000000 --- a/nuttx/sched/sem_destroy.c +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * sched/sem_destroy.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <semaphore.h> - -#include "sem_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: sem_destroy - * - * Description: - * This function is used to destroy the un-named semaphore indicated by - * 'sem'. Only a semaphore that was created using sem_init() may be - * destroyed using sem_destroy(); the effect of calling sem_destroy() with - * a named semaphore is undefined. The effect of subsequent use of the - * semaphore sem is undefined until sem is re-initialized by another call - * to sem_init(). - * - * The effect of destroying a semaphore upon which other processes are - * currently blocked is undefined. - * - * Parameters: - * sem - Semaphore to be destroyed. - * - * Return Value: - * 0 (OK), or -1 (ERROR) if unsuccessful. - * - * Assumptions: - * - ****************************************************************************/ - -int sem_destroy (FAR sem_t *sem) -{ - int ret = ERROR; - - /* Assure a valid semaphore is specified */ - - if (sem) - { - /* There is really no particular action that we need - * take to destroy a semaphore. We will just reset - * the count to some reasonable value (1) and release - * ownership. - * - * Check if other threads are waiting on the semaphore. - * In this case, the behavior is undefined. We will: - * leave the count unchanged but still return OK. - */ - - if (sem->semcount >= 0) - { - sem->semcount = 1; - } - - /* Release holders of the semaphore */ - - sem_destroyholder(sem); - ret = OK; - } - - return ret; -} diff --git a/nuttx/sched/sem_getvalue.c b/nuttx/sched/sem_getvalue.c deleted file mode 100644 index c78b9a50a..000000000 --- a/nuttx/sched/sem_getvalue.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * sched/sem_getvalue.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <semaphore.h> - -#include "sem_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: sem_getvalue - * - * Description: - * This function updates the location referenced by 'sval' argument to - * have the value of the semaphore referenced by 'sem' without effecting - * the state of the semaphore. The updated value represents the actual - * semaphore value that occurred at some unspecified time during the call, - * but may not reflect the actual value of the semaphore when it is - * returned to the calling task. - * - * If 'sem' is locked, the value return by sem_getvalue() will either be - * zero or a negative number whose absolute value represents the number - * of tasks waiting for the semaphore. - * - * Parameters: - * sem - Semaphore descriptor - * sval - Buffer by which the value is returned - * - * Return Value: - * 0 (OK), or -1 (ERROR) if unsuccessful - * - * Assumptions: - * - ****************************************************************************/ - -int sem_getvalue(FAR sem_t *sem, FAR int *sval) -{ - int ret = ERROR; - - if (sem && sval) - { - *sval = sem->semcount; - ret = OK; - } - - return ret; -} diff --git a/nuttx/sched/sem_init.c b/nuttx/sched/sem_init.c deleted file mode 100644 index 1cc1f1df8..000000000 --- a/nuttx/sched/sem_init.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * sched/sem_init.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <limits.h> -#include <semaphore.h> - -#include "sem_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Function: sem_init - * - * Description: - * This function initializes the UNAMED semaphore sem. Following a - * successful call to sem_init(), the semaophore may be used in subsequent - * calls to sem_wait(), sem_post(), and sem_trywait(). The semaphore - * remains usable until it is destroyed. - * - * Only sem itself may be used for performing synchronization. The result - * of referring to copies of sem in calls to sem_wait(), sem_trywait(), - * sem_post(), and sem_destroy() is undefined. - * - * Parameters: - * sem - Semaphore to be initialized - * pshared - Process sharing (not used) - * value - Semaphore initialization value - * - * Return Value: - * 0 (OK), or -1 (ERROR) if unsuccessful. - * - * Assumptions: - * - ****************************************************************************/ - -int sem_init (FAR sem_t *sem, int pshared, unsigned int value) -{ - int ret = ERROR; - - if (sem && value <= SEM_VALUE_MAX) - { - sem->semcount = (int16_t)value; -#ifdef CONFIG_PRIORITY_INHERITANCE -#if CONFIG_SEM_PREALLOCHOLDERS > 0 - sem->hlist.flink = NULL; -#endif - sem->hlist.holder = NULL; - sem->hlist.counts = 0; -#endif - ret = OK; - } - - return ret; -} |