sched/: Review and correct some stylistic inconsistencies

This commit is contained in:
Gregory Nutt
2016-08-07 08:25:30 -06:00
parent 10a7698112
commit 18ce4ff57b
28 changed files with 408 additions and 394 deletions
+14 -14
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/clock/clock_abstime2ticks.c * sched/clock/clock_abstime2ticks.c
* *
* Copyright (C) 2007, 2008, 2013-2014, 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2013-2014, 2016 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,11 +44,11 @@
#include <debug.h> #include <debug.h>
#include "clock/clock.h" #include "clock/clock.h"
/******************************************************************************** /****************************************************************************
* Private Functions * Private Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: compare_timespec * Name: compare_timespec
* *
* Description: * Description:
@@ -56,7 +56,7 @@
* Return > 0 if time b is before time a * Return > 0 if time b is before time a
* Return 0 if time a is the same as time b * Return 0 if time a is the same as time b
* *
********************************************************************************/ ****************************************************************************/
static long compare_timespec(FAR const struct timespec *a, static long compare_timespec(FAR const struct timespec *a,
FAR const struct timespec *b) FAR const struct timespec *b)
@@ -74,11 +74,11 @@ static long compare_timespec(FAR const struct timespec *a,
return (long)a->tv_nsec -(long)b->tv_nsec; return (long)a->tv_nsec -(long)b->tv_nsec;
} }
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: clock_abstime2ticks * Name: clock_abstime2ticks
* *
* Description: * Description:
@@ -93,10 +93,10 @@ static long compare_timespec(FAR const struct timespec *a,
* OK on success; A non-zero error number on failure; * OK on success; A non-zero error number on failure;
* *
* Assumptions: * Assumptions:
* Interrupts should be disabled so that the time is not changing during the * Interrupts should be disabled so that the time is not changing during
* calculation * the calculation
* *
********************************************************************************/ ****************************************************************************/
int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime, int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime,
FAR int *ticks) FAR int *ticks)
+8 -8
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/clock/clock_ticks2time.c * sched/clock/clock_ticks2time.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
@@ -31,22 +31,22 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <time.h> #include <time.h>
#include "clock/clock.h" #include "clock/clock.h"
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: clock_ticks2time * Name: clock_ticks2time
* *
* Description: * Description:
@@ -61,7 +61,7 @@
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int clock_ticks2time(int ticks, FAR struct timespec *reltime) int clock_ticks2time(int ticks, FAR struct timespec *reltime)
{ {
+13 -13
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/clock/clock_time2ticks.c * sched/clock/clock_time2ticks.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,17 +44,17 @@
#include "clock/clock.h" #include "clock/clock.h"
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: clock_time2ticks * Name: clock_time2ticks
* *
* Description: * Description:
* Convert a timespec delay to system timer ticks. This function is suitable * Convert a timespec delay to system timer ticks. This function is
* for calculating relative time delays and does not depend on the other * suitable for calculating relative time delays and does not depend on
* clock_* logic. * the other clock_* logic.
* *
* Parameters: * Parameters:
* reltime - Convert this relative time to system clock ticks. * reltime - Convert this relative time to system clock ticks.
@@ -65,15 +65,15 @@
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks) int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks)
{ {
#ifdef CONFIG_HAVE_LONG_LONG #ifdef CONFIG_HAVE_LONG_LONG
int64_t relnsec; int64_t relnsec;
/* Convert the relative time into nanoseconds. The range of the int64_t is /* Convert the relative time into nanoseconds. The range of the int64_t
* sufficiently large that there is no real need for range checking. * is sufficiently large that there is no real need for range checking.
*/ */
relnsec = (int64_t)reltime->tv_sec * NSEC_PER_SEC + relnsec = (int64_t)reltime->tv_sec * NSEC_PER_SEC +
+26 -24
View File
@@ -1,4 +1,4 @@
/************************************************************************ /****************************************************************************
* sched/clock/clock_timekeeping.c * sched/clock/clock_timekeeping.c
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
************************************************************************/ ****************************************************************************/
/************************************************************************ /****************************************************************************
* Included Files * Included Files
************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -52,9 +52,9 @@
#include "clock/clock.h" #include "clock/clock.h"
/************************************************************************ /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
************************************************************************/ ****************************************************************************/
#define NTP_MAX_ADJUST 500 #define NTP_MAX_ADJUST 500
@@ -68,13 +68,13 @@ static uint64_t g_clock_last_counter;
static uint64_t g_clock_mask; static uint64_t g_clock_mask;
static long g_clock_adjust; static long g_clock_adjust;
/************************************************************************ /****************************************************************************
* Private Functions * Private Functions
************************************************************************/ ****************************************************************************/
/************************************************************************ /****************************************************************************
* Name: clock_get_current_time * Name: clock_get_current_time
************************************************************************/ ****************************************************************************/
static int clock_get_current_time(FAR struct timespec *ts, static int clock_get_current_time(FAR struct timespec *ts,
FAR struct timespec *base) FAR struct timespec *base)
@@ -114,31 +114,31 @@ errout_in_critical_section:
return ret; return ret;
} }
/************************************************************************ /****************************************************************************
* Public Functions * Public Functions
************************************************************************/ ****************************************************************************/
/************************************************************************ /****************************************************************************
* Name: clock_timekeeping_get_monotonic_time * Name: clock_timekeeping_get_monotonic_time
************************************************************************/ ****************************************************************************/
int clock_timekeeping_get_monotonic_time(FAR struct timespec *ts) int clock_timekeeping_get_monotonic_time(FAR struct timespec *ts)
{ {
return clock_get_current_time(ts, &g_clock_monotonic_time); return clock_get_current_time(ts, &g_clock_monotonic_time);
} }
/************************************************************************ /****************************************************************************
* Name: clock_timekeeping_get_wall_time * Name: clock_timekeeping_get_wall_time
************************************************************************/ ****************************************************************************/
int clock_timekeeping_get_wall_time(FAR struct timespec *ts) int clock_timekeeping_get_wall_time(FAR struct timespec *ts)
{ {
return clock_get_current_time(ts, &g_clock_wall_time); return clock_get_current_time(ts, &g_clock_wall_time);
} }
/************************************************************************ /****************************************************************************
* Name: clock_timekeeping_set_wall_time * Name: clock_timekeeping_set_wall_time
************************************************************************/ ****************************************************************************/
int clock_timekeeping_set_wall_time(FAR struct timespec *ts) int clock_timekeeping_set_wall_time(FAR struct timespec *ts)
{ {
@@ -163,7 +163,7 @@ errout_in_critical_section:
return ret; return ret;
} }
/**************************************************************************** /********************************************************************************
* Name: adjtime * Name: adjtime
* *
* Description: * Description:
@@ -226,9 +226,9 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
return OK; return OK;
} }
/************************************************************************ /****************************************************************************
* Name: clock_update_wall_time * Name: clock_update_wall_time
************************************************************************/ ****************************************************************************/
void clock_update_wall_time(void) void clock_update_wall_time(void)
{ {
@@ -304,9 +304,9 @@ errout_in_critical_section:
leave_critical_section(flags); leave_critical_section(flags);
} }
/************************************************************************ /****************************************************************************
* Name: clock_inittimekeeping * Name: clock_inittimekeeping
************************************************************************/ ****************************************************************************/
void clock_inittimekeeping(void) void clock_inittimekeeping(void)
{ {
@@ -318,7 +318,9 @@ void clock_inittimekeeping(void)
(void)up_rtc_getdatetime(&rtctime); (void)up_rtc_getdatetime(&rtctime);
/* And use the broken-errout_in_critical_section time to initialize the system time */ /* And use the broken-errout_in_critical_section time to initialize the
* system time.
*/
g_clock_wall_time.tv_sec = mktime(&rtctime); g_clock_wall_time.tv_sec = mktime(&rtctime);
g_clock_wall_time.tv_nsec = 0; g_clock_wall_time.tv_nsec = 0;
+6 -6
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/clock/clock_timespec_add.c * sched/clock/clock_timespec_add.c
* *
* Copyright (C) 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2015 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,9 +44,9 @@
#include "clock/clock.h" #include "clock/clock.h"
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: clock_timespec_add * Name: clock_timespec_add
+6 -6
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/clock/clock_timespec_subtract.c * sched/clock/clock_timespec_subtract.c
* *
* Copyright (C) 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2015 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,9 +44,9 @@
#include "clock/clock.h" #include "clock/clock.h"
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: clock_timespec_subtract * Name: clock_timespec_subtract
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* env_getenv.c * sched/environ/env_getenv.c
* *
* Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* env_getenvironptr.c * sched/environ/env_getenvironptr.c
* *
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* group_setupstreams.c * sched/group/group_setupstreams.c
* *
* Copyright (C) 2007-2008, 2010-2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2008, 2010-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+17 -16
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/pthread/pthread_barriedestroy.c * sched/pthread/pthread_barriedestroy.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,20 +44,21 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: pthread_barrier_destroy * Name: pthread_barrier_destroy
* *
* Description: * Description:
* The pthread_barrier_destroy() function destroys the barrier referenced by * The pthread_barrier_destroy() function destroys the barrier referenced
* 'barrier' and releases any resources used by the barrier. The effect of * by 'barrier' and releases any resources used by the barrier. The effect
* subsequent use of the barrier is undefined until the barrier is * of subsequent use of the barrier is undefined until the barrier is
* reinitialized by another call to pthread_barrier_init(). The results are * reinitialized by another call to pthread_barrier_init(). The result
* undefined if pthread_barrier_destroy() is called when any thread is blocked * are undefined if pthread_barrier_destroy() is called when any thread is
* on the barrier, or if this function is called with an uninitialized barrier. * blocked on the barrier, or if this function is called with an
* uninitialized barrier.
* *
* Parameters: * Parameters:
* barrier - barrier to be destroyed. * barrier - barrier to be destroyed.
@@ -65,13 +66,13 @@
* Return Value: * Return Value:
* 0 (OK) on success or on of the following error numbers: * 0 (OK) on success or on of the following error numbers:
* *
* EBUSY The implementation has detected an attempt to destroy a barrier while * EBUSY The implementation has detected an attempt to destroy a barrier
* it is in use. * while it is in use.
* EINVAL The value specified by barrier is invalid. * EINVAL The value specified by barrier is invalid.
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int pthread_barrier_destroy(FAR pthread_barrier_t *barrier) int pthread_barrier_destroy(FAR pthread_barrier_t *barrier)
{ {
+26 -25
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/pthread/pthread_barrieinit.c * sched/pthread/pthread_barrieinit.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,44 +44,45 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: pthread_barrier_init * Name: pthread_barrier_init
* *
* Description: * Description:
* The pthread_barrier_init() function allocates any resources required to use * The pthread_barrier_init() function allocates any resources required to
* the barrier referenced by 'barrier' and initialized the barrier with the * use the barrier referenced by 'barrier' and initialized the barrier
* attributes referenced by attr. If attr is NULL, the default barrier * with the attributes referenced by attr. If attr is NULL, the default
* attributes will be used. The results are undefined if pthread_barrier_init() * barrier attributes will be used. The results are undefined if
* is called when any thread is blocked on the barrier. The results are * pthread_barrier_init() is called when any thread is blocked on the
* undefined if a barrier is used without first being initialized. The results * barrier. The results are undefined if a barrier is used without first
* are undefined if pthread_barrier_init() is called specifying an already * being initialized. The results are undefined if pthread_barrier_init()
* initialized barrier. * is called specifying an already initialized barrier.
* *
* Parameters: * Parameters:
* barrier - the barrier to be initialized * barrier - the barrier to be initialized
* attr - barrier attributes to be used in the initialization. * attr - barrier attributes to be used in the initialization.
* count - the count to be associated with the barrier. The count argument * count - the count to be associated with the barrier. The count
* specifies the number of threads that must call pthread_barrier_wait() before * argument specifies the number of threads that must call
* any of them successfully return from the call. The value specified by * pthread_barrier_wait() before any of them successfully return from
* count must be greater than zero. * the call. The value specified by count must be greater than zero.
* *
* Return Value: * Return Value:
* 0 (OK) on success or on of the following error numbers: * 0 (OK) on success or on of the following error numbers:
* *
* EAGAIN The system lacks the necessary resources to initialize another barrier. * EAGAIN The system lacks the necessary resources to initialize another
* EINVAL The barrier reference is invalid, or the values specified by attr are * barrier. EINVAL The barrier reference is invalid, or the values
* invalid, or the value specified by count is equal to zero. * specified by attr are invalid, or the value specified by count
* is equal to zero.
* ENOMEM Insufficient memory exists to initialize the barrier. * ENOMEM Insufficient memory exists to initialize the barrier.
* EBUSY The implementation has detected an attempt to reinitialize a barrier * EBUSY The implementation has detected an attempt to reinitialize a
* while it is in use. * barrier while it is in use.
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int pthread_barrier_init(FAR pthread_barrier_t *barrier, int pthread_barrier_init(FAR pthread_barrier_t *barrier,
FAR const pthread_barrierattr_t *attr, unsigned int count) FAR const pthread_barrierattr_t *attr, unsigned int count)
+33 -31
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/pthread/pthread_barrierwait.c * sched/pthread/pthread_barrierwait.c
* *
* Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -45,41 +45,43 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: pthread_barrier_wait * Name: pthread_barrier_wait
* *
* Description: * Description:
* The pthread_barrier_wait() function synchronizse participating threads at * The pthread_barrier_wait() function synchronizse participating threads
* the barrier referenced by 'barrier'. The calling thread is blocked until * at the barrier referenced by 'barrier'. The calling thread is blocked
* the required number of threads have called pthread_barrier_wait() specifying * until the required number of threads have called pthread_barrier_wait()
* the same 'barrier'. When the required number of threads have called * specifying the same 'barrier'. When the required number of threads
* pthread_barrier_wait() specifying the 'barrier', the constant * have called pthread_barrier_wait() specifying the 'barrier', the
* PTHREAD_BARRIER_SERIAL_THREAD will be returned to one unspecified thread * constant PTHREAD_BARRIER_SERIAL_THREAD will be returned to one
* and zero will be returned to each of the remaining threads. At this point, * unspecified thread and zero will be returned to each of the remaining
* the barrier will be reset to the state it had as a result of the most recent * threads. At this point, the barrier will be reset to the state it had
* pthread_barrier_init() function that referenced it. * as a result of the most recent pthread_barrier_init() function that
* referenced it.
* *
* The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in pthread.h and its * The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in pthread.h and
* value must be distinct from any other value returned by pthread_barrier_wait(). * its value must be distinct from any other value returned by
* pthread_barrier_wait().
* *
* The results are undefined if this function is called with an uninitialized * The results are undefined if this function is called with an
* barrier. * uninitialized barrier.
* *
* If a signal is delivered to a thread blocked on a barrier, upon return from * If a signal is delivered to a thread blocked on a barrier, upon return
* the signal handler the thread will resume waiting at the barrier if the barrier * from the signal handler the thread will resume waiting at the barrier
* wait has not completed; otherwise, the thread will continue as normal from * if the barrier wait has not completed; otherwise, the thread will
* the completed barrier wait. Until the thread in the signal handler returns * continue as normal from the completed barrier wait. Until the thread in
* from it, it is unspecified whether other threads may proceed past the barrier * the signal handler returns from it, it is unspecified whether other
* once they have all reached it. * threads may proceed past the barrier once they have all reached it.
* *
* A thread that has blocked on a barrier will not prevent any unblocked thread * A thread that has blocked on a barrier will not prevent any unblocked
* that is eligible to use the same processing resources from eventually making * thread that is eligible to use the same processing resources from
* forward progress in its execution. Eligibility for processing resources will * eventually making forward progress in its execution. Eligibility for
* be determined by the scheduling policy. * processing resources will be determined by the scheduling policy.
* *
* Parameters: * Parameters:
* barrier - the barrier to wait on * barrier - the barrier to wait on
@@ -89,7 +91,7 @@
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int pthread_barrier_wait(FAR pthread_barrier_t *barrier) int pthread_barrier_wait(FAR pthread_barrier_t *barrier)
{ {
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* pthread_findjoininfo.c * sched/pthread/pthread_findjoininfo.c
* *
* Copyright (C) 2007, 2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* pthread_getaffinity.c * sched/pthread/pthread_getaffinity.c
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* pthread_getschedparam.c * sched/pthread/pthread_getschedparam.c
* *
* Copyright (C) 2007, 2008, 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* pthread_join.c * sched/pthread/pthread_join.c
* *
* Copyright (C) 2007, 2008, 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+15 -15
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/pthread/pthread_once.c * sched/pthread/pthread_once.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -45,26 +45,26 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: pthread_once * Name: pthread_once
* *
* Description: * Description:
* The first call to pthread_once() by any thread with a given once_control, * The first call to pthread_once() by any thread with a given
* will call the init_routine with no arguments. Subsequent calls to * once_control, will call the init_routine with no arguments. Subsequent
* pthread_once() with the same once_control will have no effect. On return * calls to pthread_once() with the same once_control will have no effect.
* from pthread_once(), init_routine will have completed. * On return from pthread_once(), init_routine will have completed.
* *
* Parameters: * Parameters:
* once_control - Determines if init_routine should be called. once_control * once_control - Determines if init_routine should be called.
* should be declared and initializeed as follows: * once_control should be declared and initializeed as follows:
* *
* pthread_once_t once_control = PTHREAD_ONCE_INIT; * pthread_once_t once_control = PTHREAD_ONCE_INIT;
* *
* PTHREAD_ONCE_INIT is defined in pthread.h * PTHREAD_ONCE_INIT is defined in pthread.h
* init_routine - The initialization routine that will be called once. * init_routine - The initialization routine that will be called once.
* *
* Return Value: * Return Value:
@@ -73,7 +73,7 @@
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int pthread_once(FAR pthread_once_t *once_control, int pthread_once(FAR pthread_once_t *once_control,
CODE void (*init_routine)(void)) CODE void (*init_routine)(void))
+8 -8
View File
@@ -1,4 +1,4 @@
/****************************************************************************************** /****************************************************************************
* sched/pthread/pthread_setcancelstate.c * sched/pthread/pthread_setcancelstate.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
@@ -31,23 +31,23 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
******************************************************************************************/ ****************************************************************************/
/****************************************************************************************** /****************************************************************************
* Included Files * Included Files
******************************************************************************************/ ****************************************************************************/
#include <pthread.h> #include <pthread.h>
#include <errno.h> #include <errno.h>
#include "sched/sched.h" #include "sched/sched.h"
/****************************************************************************************** /****************************************************************************
* Public Functions * Public Functions
******************************************************************************************/ ****************************************************************************/
/****************************************************************************************** /****************************************************************************
* Name: pthread_setcancelstate * Name: pthread_setcancelstate
******************************************************************************************/ ****************************************************************************/
int pthread_setcancelstate(int state, FAR int *oldstate) int pthread_setcancelstate(int state, FAR int *oldstate)
{ {
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* shced/sched_removereadytorun.c * sched/sched_removereadytorun.c
* *
* Copyright (C) 2007-2009, 2012, 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+41 -39
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_create.c * sched/timer/timer_create.c
* *
* Copyright (C) 2007-2009, 2011, 2014-2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2011, 2014-2016 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -53,17 +53,17 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Private Functions * Private Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_allocate * Name: timer_allocate
* *
* Description: * Description:
* Allocate one POSIX timer and place it into the allocated timer list. * Allocate one POSIX timer and place it into the allocated timer list.
* *
********************************************************************************/ ****************************************************************************/
static FAR struct posix_timer_s *timer_allocate(void) static FAR struct posix_timer_s *timer_allocate(void)
{ {
@@ -112,32 +112,33 @@ static FAR struct posix_timer_s *timer_allocate(void)
return ret; return ret;
} }
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_create * Name: timer_create
* *
* Description: * Description:
* The timer_create() function creates per-thread timer using the specified * The timer_create() function creates per-thread timer using the
* clock, clock_id, as the timing base. The timer_create() function returns, in * specified clock, clock_id, as the timing base. The timer_create()
* the location referenced by timerid, a timer ID of type timer_t used to identify * function returns, in the location referenced by timerid, a timer ID of
* the timer in timer requests. This timer ID is unique until the timer is * type timer_t used to identify the timer in timer requests. This timer
* deleted. The particular clock, clock_id, is defined in <time.h>. The timer * ID is unique until the timer is deleted. The particular clock, clock_id,
* whose ID is returned will be in a disarmed state upon return from * is defined in <time.h>. The timer whose ID is returned will be in a
* timer_create(). * disarmed state upon return from timer_create().
* *
* The evp argument, if non-NULL, points to a sigevent structure. This structure * The evp argument, if non-NULL, points to a sigevent structure. This
* is allocated by the called and defines the asynchronous notification to occur. * structure is allocated by the called and defines the asynchronous
* If the evp argument is NULL, the effect is as if the evp argument pointed to * notification to occur. If the evp argument is NULL, the effect is as
* a sigevent structure with the sigev_notify member having the value SIGEV_SIGNAL, * if the evp argument pointed to a sigevent structure with the
* the sigev_signo having a default signal number, and the sigev_value member * sigev_notify member having the value SIGEV_SIGNAL, the sigev_signo
* having the value of the timer ID. * having a default signal number, and the sigev_value member having the
* value of the timer ID.
* *
* Each implementation defines a set of clocks that can be used as timing bases * Each implementation defines a set of clocks that can be used as timing
* for per-thread timers. All implementations shall support a clock_id of * bases for per-thread timers. All implementations shall support a
* CLOCK_REALTIME. * clock_id of CLOCK_REALTIME.
* *
* Parameters: * Parameters:
* clockid - Specifies the clock to use as the timing base. * clockid - Specifies the clock to use as the timing base.
@@ -148,30 +149,31 @@ static FAR struct posix_timer_s *timer_allocate(void)
* Return Value: * Return Value:
* If the call succeeds, timer_create() will return 0 (OK) and update the * If the call succeeds, timer_create() will return 0 (OK) and update the
* location referenced by timerid to a timer_t, which can be passed to the * location referenced by timerid to a timer_t, which can be passed to the
* other per-thread timer calls. If an error occurs, the function will return * other per-thread timer calls. If an error occurs, the function will
* a value of -1 (ERROR) and set errno to indicate the error. * return a value of -1 (ERROR) and set errno to indicate the error.
* *
* EAGAIN - The system lacks sufficient signal queuing resources to honor the * EAGAIN - The system lacks sufficient signal queuing resources to honor
* request. * the request.
* EAGAIN - The calling process has already created all of the timers it is * EAGAIN - The calling process has already created all of the timers it
* allowed by this implementation. * is allowed by this implementation.
* EINVAL - The specified clock ID is not defined. * EINVAL - The specified clock ID is not defined.
* ENOTSUP - The implementation does not support the creation of a timer attached * ENOTSUP - The implementation does not support the creation of a timer
* to the CPU-time clock that is specified by clock_id and associated with a * attached to the CPU-time clock that is specified by clock_id and
* thread different thread invoking timer_create(). * associated with a thread different thread invoking timer_create().
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timerid) int timer_create(clockid_t clockid, FAR struct sigevent *evp,
FAR timer_t *timerid)
{ {
FAR struct posix_timer_s *ret; FAR struct posix_timer_s *ret;
WDOG_ID wdog; WDOG_ID wdog;
/* Sanity checks. Also, we support only CLOCK_REALTIME */ /* Sanity checks. Also, we support only CLOCK_REALTIME */
if (!timerid || clockid != CLOCK_REALTIME) if (timerid == NULL || clockid != CLOCK_REALTIME)
{ {
set_errno(EINVAL); set_errno(EINVAL);
return ERROR; return ERROR;
+16 -16
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_delete.c * sched/timer/timer_delete.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -46,34 +46,34 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_delete * Name: timer_delete
* *
* Description: * Description:
* The timer_delete() function deletes the specified timer, timerid, previously * The timer_delete() function deletes the specified timer, timerid,
* created by the timer_create() function. If the timer is armed when * previously created by the timer_create() function. If the timer is
* timer_delete() is called, the timer will be automatically disarmed before * armed when timer_delete() is called, the timer will be automatically
* removal. The disposition of pending signals for the deleted timer is * disarmed before removal. The disposition of pending signals for the
* unspecified. * deleted timer is unspecified.
* *
* Parameters: * Parameters:
* timerid - The per-thread timer, previously created by the call to * timerid - The per-thread timer, previously created by the call to
* timer_create(), to be deleted. * timer_create(), to be deleted.
* *
* Return Value: * Return Value:
* If the call succeeds, timer_create() will return 0 (OK). Otherwise, the * If the call succeeds, timer_create() will return 0 (OK). Otherwise,
* function will return a value of -1 (ERROR) and set errno to indicate the * the function will return a value of -1 (ERROR) and set errno to
* error. * indicate the error.
* *
* EINVAL - The timer specified timerid is not valid. * EINVAL - The timer specified timerid is not valid.
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int timer_delete(timer_t timerid) int timer_delete(timer_t timerid)
{ {
+27 -25
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_getoverrun.c * sched/timer/timer_getoverrun.c
* *
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -46,30 +46,31 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_getoverrun * Name: timer_getoverrun
* *
* Description: * Description:
* Only a single signal will be queued to the process for a given timer at any * Only a single signal will be queued to the process for a given timer at
* point in time. When a timer for which a signal is still pending expires, no * any point in time. When a timer for which a signal is still pending
* signal will be queued, and a timer overrun will occur. When a timer * expires, no signal will be queued, and a timer overrun will occur. When
* expiration signal is delivered to or accepted by a process, if the * a timer expiration signal is delivered to or accepted by a process, if
* implementation supports the Realtime Signals Extension, the * the implementation supports the Realtime Signals Extension, the
* timer_getoverrun() function will return the timer expiration overrun count for * timer_getoverrun() function will return the timer expiration overrun
* the specified timer. The overrun count returned contains the number of extra * count for the specified timer. The overrun count returned contains the
* timer expirations that occurred between the time the signal was generated * number of extra timer expirations that occurred between the time the
* (queued) and when it was delivered or accepted, up to but not including an * signal was generated (queued) and when it was delivered or accepted, up
* implementation-defined maximum of DELAYTIMER_MAX. If the number of such * to but not including an implementation-defined maximum of
* extra expirations is greater than or equal to DELAYTIMER_MAX, then the * DELAYTIMER_MAX. If the number of such extra expirations is greater than
* overrun count will be set to DELAYTIMER_MAX. The value returned by * or equal to DELAYTIMER_MAX, then the overrun count will be set to
* timer_getoverrun() will apply to the most recent expiration signal delivery * DELAYTIMER_MAX. The value returned by timer_getoverrun() will apply to
* or acceptance for the timer. If no expiration signal has been delivered * the most recent expiration signal delivery or acceptance for the timer.
* for the timer, or if the Realtime Signals Extension is not supported, the * If no expiration signal has been delivered for the timer, or if the
* return value of timer_getoverrun() is unspecified. * Realtime Signals Extension is not supported, the return value of
* timer_getoverrun() is unspecified.
* *
* Parameters: * Parameters:
* timerid - The pre-thread timer, previously created by the call to * timerid - The pre-thread timer, previously created by the call to
@@ -77,14 +78,15 @@
* *
* Return Value: * Return Value:
* If the timer_getoverrun() function succeeds, it will return the timer * If the timer_getoverrun() function succeeds, it will return the timer
* expiration overrun count as explained above. timer_getoverrun() will fail if: * expiration overrun count as explained above. timer_getoverrun() will
* fail if:
* *
* EINVAL - The timerid argument does not correspond to an ID returned by * EINVAL - The timerid argument does not correspond to an ID returned by
* timer_create() but not yet deleted by timer_delete(). * timer_create() but not yet deleted by timer_delete().
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int timer_getoverrun(timer_t timerid) int timer_getoverrun(timer_t timerid)
{ {
+18 -17
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_gettime.c * sched/timer/timer_gettime.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -47,21 +47,22 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_gettime * Name: timer_gettime
* *
* Description: * Description:
* The timer_gettime() function will store the amount of time until the * The timer_gettime() function will store the amount of time until the
* specified timer, timerid, expires and the reload value of the timer into the * specified timer, timerid, expires and the reload value of the timer
* space pointed to by the value argument. The it_value member of this structure * into the space pointed to by the value argument. The it_value member
* will contain the amount of time before the timer expires, or zero if the timer * of this structure will contain the amount of time before the timer
* is disarmed. This value is returned as the interval until timer expiration, * expires, or zero if the timer is disarmed. This value is returned as
* even if the timer was armed with absolute time. The it_interval member of * the interval until timer expiration, even if the timer was armed with
* value will contain the reload value last set by timer_settime(). * absolute time. The it_interval member of value will contain the reload
* value last set by timer_settime().
* *
* Parameters: * Parameters:
* timerid - The pre-thread timer, previously created by the call to * timerid - The pre-thread timer, previously created by the call to
@@ -69,8 +70,8 @@
* *
* Return Value: * Return Value:
* If the timer_gettime() succeeds, a value of 0 (OK) will be returned. * If the timer_gettime() succeeds, a value of 0 (OK) will be returned.
* If an error occurs, the value -1 (ERROR) will be returned, and errno set to * If an error occurs, the value -1 (ERROR) will be returned, and errno
* indicate the error. * set to indicate the error.
* *
* EINVAL - The timerid argument does not correspond to an ID returned by * EINVAL - The timerid argument does not correspond to an ID returned by
* timer_create() but not yet deleted by timer_delete(). * timer_create() but not yet deleted by timer_delete().
@@ -80,7 +81,7 @@
* by this function could be significantly more than that actual time * by this function could be significantly more than that actual time
* remaining on the timer at any time. * remaining on the timer at any time.
* *
********************************************************************************/ ****************************************************************************/
int timer_gettime(timer_t timerid, FAR struct itimerspec *value) int timer_gettime(timer_t timerid, FAR struct itimerspec *value)
{ {
+24 -26
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_initialize.c * sched/timer/timer_initialize.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
@@ -51,9 +51,9 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Private Data * Private Data
********************************************************************************/ ****************************************************************************/
/* These are the preallocated times */ /* These are the preallocated times */
@@ -61,28 +61,28 @@
static struct posix_timer_s g_prealloctimers[CONFIG_PREALLOC_TIMERS]; static struct posix_timer_s g_prealloctimers[CONFIG_PREALLOC_TIMERS];
#endif #endif
/******************************************************************************** /****************************************************************************
* Public Data * Public Data
********************************************************************************/ ****************************************************************************/
/* This is a list of free, preallocated timer structures */
#if CONFIG_PREALLOC_TIMERS > 0 #if CONFIG_PREALLOC_TIMERS > 0
/* This is a list of free, preallocated timer structures */
volatile sq_queue_t g_freetimers; volatile sq_queue_t g_freetimers;
#endif #endif
/* This is a list of instantiated timer structures -- active and inactive. The /* This is a list of instantiated timer structures -- active and inactive.
* timers are place on this list by timer_create() and removed from the list by * The timers are place on this list by timer_create() and removed from the
* timer_delete() or when the owning thread exits. * list by timer_delete() or when the owning thread exits.
*/ */
volatile sq_queue_t g_alloctimers; volatile sq_queue_t g_alloctimers;
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_initialize * Name: timer_initialize
* *
* Description: * Description:
@@ -94,9 +94,7 @@ volatile sq_queue_t g_alloctimers;
* Return Value: * Return Value:
* None * None
* *
* Assumptions: ****************************************************************************/
*
********************************************************************************/
void weak_function timer_initialize(void) void weak_function timer_initialize(void)
{ {
@@ -120,12 +118,12 @@ void weak_function timer_initialize(void)
sq_init((FAR sq_queue_t *)&g_alloctimers); sq_init((FAR sq_queue_t *)&g_alloctimers);
} }
/******************************************************************************** /****************************************************************************
* Name: timer_deleteall * Name: timer_deleteall
* *
* Description: * Description:
* This function is called whenever a thread exits. Any timers owned by that * This function is called whenever a thread exits. Any timers owned by
* thread are deleted as though called by timer_delete(). * that thread are deleted as though called by timer_delete().
* *
* It is provided in this file so that it can be weakly defined but also, * It is provided in this file so that it can be weakly defined but also,
* like timer_intitialize(), be brought into the link whenever the timer * like timer_intitialize(), be brought into the link whenever the timer
@@ -137,9 +135,7 @@ void weak_function timer_initialize(void)
* Return Value: * Return Value:
* None * None
* *
* Assumptions: ****************************************************************************/
*
********************************************************************************/
void weak_function timer_deleteall(pid_t pid) void weak_function timer_deleteall(pid_t pid)
{ {
@@ -148,7 +144,9 @@ void weak_function timer_deleteall(pid_t pid)
irqstate_t flags; irqstate_t flags;
flags = enter_critical_section(); flags = enter_critical_section();
for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) for (timer = (FAR struct posix_timer_s *)g_alloctimers.head;
timer != NULL;
timer = next)
{ {
next = timer->flink; next = timer->flink;
if (timer->pt_owner == pid) if (timer->pt_owner == pid)
+20 -19
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_release.c * sched/timer/timer_release.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -49,19 +49,19 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Private Functions * Private Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_free * Name: timer_free
* *
* Description: * Description:
* Remove the timer from the allocated timer list and free it or return it to * Remove the timer from the allocated timer list and free it or return it
* the free list (depending on whether or not the timer is one of the * to the free list (depending on whether or not the timer is one of the
* preallocated timers) * preallocated timers)
* *
********************************************************************************/ ****************************************************************************/
static inline void timer_free(struct posix_timer_s *timer) static inline void timer_free(struct posix_timer_s *timer)
{ {
@@ -90,29 +90,30 @@ static inline void timer_free(struct posix_timer_s *timer)
} }
} }
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_release * Name: timer_release
* *
* Description: * Description:
* timer_release implements the heart of timer_delete. It is private to the * timer_release implements the heart of timer_delete. It is private to
* the OS internals and differs only in that return value of 1 means that the * the OS internals and differs only in that return value of 1 means that
* timer was not actually deleted. * the timer was not actually deleted.
* *
* Parameters: * Parameters:
* timer - The per-thread timer, previously created by the call to * timer - The per-thread timer, previously created by the call to
* timer_create(), to be deleted. * timer_create(), to be deleted.
* *
* Return Value: * Return Value:
* If the call succeeds, timer_release() will return 0 (OK) or 1 (meaning that * If the call succeeds, timer_release() will return 0 (OK) or 1 (meaning
* the timer is still valid). Otherwise, the function will return a negated errno: * that the timer is still valid). Otherwise, the function will return a
* negated errno value:
* *
* -EINVAL - The timer specified timerid is not valid. * -EINVAL - The timer specified timerid is not valid.
* *
********************************************************************************/ ****************************************************************************/
int timer_release(FAR struct posix_timer_s *timer) int timer_release(FAR struct posix_timer_s *timer)
{ {
+65 -62
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/timer/timer_settime.c * sched/timer/timer_settime.c
* *
* Copyright (C) 2007-2010, 2013-2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2010, 2013-2016 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -53,19 +53,20 @@
#ifndef CONFIG_DISABLE_POSIX_TIMERS #ifndef CONFIG_DISABLE_POSIX_TIMERS
/******************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
********************************************************************************/ ****************************************************************************/
static inline void timer_signotify(FAR struct posix_timer_s *timer); static inline void timer_signotify(FAR struct posix_timer_s *timer);
static inline void timer_restart(FAR struct posix_timer_s *timer, wdparm_t itimer); static inline void timer_restart(FAR struct posix_timer_s *timer,
wdparm_t itimer);
static void timer_timeout(int argc, wdparm_t itimer); static void timer_timeout(int argc, wdparm_t itimer);
/******************************************************************************** /****************************************************************************
* Private Functions * Private Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_signotify * Name: timer_signotify
* *
* Description: * Description:
@@ -81,7 +82,7 @@ static void timer_timeout(int argc, wdparm_t itimer);
* Assumptions: * Assumptions:
* This function executes in the context of the watchod timer interrupt. * This function executes in the context of the watchod timer interrupt.
* *
********************************************************************************/ ****************************************************************************/
static inline void timer_signotify(FAR struct posix_timer_s *timer) static inline void timer_signotify(FAR struct posix_timer_s *timer)
{ {
@@ -121,7 +122,7 @@ static inline void timer_signotify(FAR struct posix_timer_s *timer)
#endif #endif
} }
/******************************************************************************** /****************************************************************************
* Name: timer_restart * Name: timer_restart
* *
* Description: * Description:
@@ -136,7 +137,7 @@ static inline void timer_signotify(FAR struct posix_timer_s *timer)
* Assumptions: * Assumptions:
* This function executes in the context of the watchdog timer interrupt. * This function executes in the context of the watchdog timer interrupt.
* *
********************************************************************************/ ****************************************************************************/
static inline void timer_restart(FAR struct posix_timer_s *timer, static inline void timer_restart(FAR struct posix_timer_s *timer,
wdparm_t itimer) wdparm_t itimer)
@@ -146,12 +147,12 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
if (timer->pt_delay) if (timer->pt_delay)
{ {
timer->pt_last = timer->pt_delay; timer->pt_last = timer->pt_delay;
(void)wd_start(timer->pt_wdog, timer->pt_delay, (wdentry_t)timer_timeout, (void)wd_start(timer->pt_wdog, timer->pt_delay,
1, itimer); (wdentry_t)timer_timeout, 1, itimer);
} }
} }
/******************************************************************************** /****************************************************************************
* Name: timer_timeout * Name: timer_timeout
* *
* Description: * Description:
@@ -169,13 +170,14 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
* Assumptions: * Assumptions:
* This function executes in the context of the watchod timer interrupt. * This function executes in the context of the watchod timer interrupt.
* *
********************************************************************************/ ****************************************************************************/
static void timer_timeout(int argc, wdparm_t itimer) static void timer_timeout(int argc, wdparm_t itimer)
{ {
#ifndef CONFIG_CAN_PASS_STRUCTS #ifndef CONFIG_CAN_PASS_STRUCTS
/* On many small machines, pointers are encoded and cannot be simply cast from /* On many small machines, pointers are encoded and cannot be simply cast
* wdparm_t to struct tcb_s *. The following union works around this (see wdogparm_t). * from wdparm_t to struct tcb_s *. The following union works around this
* (see wdogparm_t).
*/ */
union union
@@ -186,9 +188,9 @@ static void timer_timeout(int argc, wdparm_t itimer)
u.itimer = itimer; u.itimer = itimer;
/* Send the specified signal to the specified task. Increment the reference /* Send the specified signal to the specified task. Increment the
* count on the timer first so that will not be deleted until after the * reference count on the timer first so that will not be deleted until
* signal handler returns. * after the signal handler returns.
*/ */
u.timer->pt_crefs++; u.timer->pt_crefs++;
@@ -207,9 +209,9 @@ static void timer_timeout(int argc, wdparm_t itimer)
#else #else
FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)itimer; FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)itimer;
/* Send the specified signal to the specified task. Increment the reference /* Send the specified signal to the specified task. Increment the
* count on the timer first so that will not be deleted until after the * reference count on the timer first so that will not be deleted until
* signal handler returns. * after the signal handler returns.
*/ */
timer->pt_crefs++; timer->pt_crefs++;
@@ -228,62 +230,63 @@ static void timer_timeout(int argc, wdparm_t itimer)
#endif #endif
} }
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: timer_settime * Name: timer_settime
* *
* Description: * Description:
* The timer_settime() function sets the time until the next expiration of the * The timer_settime() function sets the time until the next expiration of
* timer specified by timerid from the it_value member of the value argument * the timer specified by timerid from the it_value member of the value
* and arm the timer if the it_value member of value is non-zero. If the * argument and arm the timer if the it_value member of value is non-zero.
* specified timer was already armed when timer_settime() is called, this call * If the specified timer was already armed when timer_settime() is
* will reset the time until next expiration to the value specified. If the * called, this call will reset the time until next expiration to the
* it_value member of value is zero, the timer will be disarmed. The effect * value specified. If the it_value member of value is zero, the timer
* of disarming or resetting a timer with pending expiration notifications is * will be disarmed. The effect of disarming or resetting a timer with
* unspecified. * pending expiration notifications is unspecified.
* *
* If the flag TIMER_ABSTIME is not set in the argument flags, timer_settime() * If the flag TIMER_ABSTIME is not set in the argument flags,
* will behave as if the time until next expiration is set to be equal to the * timer_settime() will behave as if the time until next expiration is set
* interval specified by the it_value member of value. That is, the timer will * to be equal to the interval specified by the it_value member of value.
* expire in it_value nanoseconds from when the call is made. If the flag * That is, the timer will expire in it_value nanoseconds from when the
* TIMER_ABSTIME is set in the argument flags, timer_settime() will behave as * call is made. If the flag TIMER_ABSTIME is set in the argument flags,
* if the time until next expiration is set to be equal to the difference between * timer_settime() will behave as if the time until next expiration is set
* the absolute time specified by the it_value member of value and the current * to be equal to the difference between the absolute time specified by
* value of the clock associated with timerid. That is, the timer will expire * the it_value member of value and the current value of the clock
* when the clock reaches the value specified by the it_value member of value. * associated with timerid. That is, the timer will expire when the clock
* If the specified time has already passed, the function will succeed and the * reaches the value specified by the it_value member of value. If the
* specified time has already passed, the function will succeed and the
* expiration notification will be made. * expiration notification will be made.
* *
* The reload value of the timer will be set to the value specified by the * The reload value of the timer will be set to the value specified by the
* it_interval member of value. When a timer is armed with a non-zero * it_interval member of value. When a timer is armed with a non-zero
* it_interval, a periodic (or repetitive) timer is specified. * it_interval, a periodic (or repetitive) timer is specified.
* *
* Time values that are between two consecutive non-negative integer multiples * Time values that are between two consecutive non-negative integer
* of the resolution of the specified timer will be rounded up to the larger * multiples of the resolution of the specified timer will be rounded up
* multiple of the resolution. Quantization error will not cause the timer to * to the larger multiple of the resolution. Quantization error will not
* expire earlier than the rounded time value. * cause the timer to expire earlier than the rounded time value.
* *
* If the argument ovalue is not NULL, the timer_settime() function will store, * If the argument ovalue is not NULL, the timer_settime() function will
* in the location referenced by ovalue, a value representing the previous * store, in the location referenced by ovalue, a value representing the
* amount of time before the timer would have expired, or zero if the timer was * previous amount of time before the timer would have expired, or zero if
* disarmed, together with the previous timer reload value. Timers will not * the timer was disarmed, together with the previous timer reload value.
* expire before their scheduled time. * Timers will not expire before their scheduled time.
* *
* Parameters: * Parameters:
* timerid - The pre-thread timer, previously created by the call to * timerid - The pre-thread timer, previously created by the call to
* timer_create(), to be be set. * timer_create(), to be be set.
* flags - Specifie characteristics of the timer (see above) * flags - Specifie characteristics of the timer (see above)
* value - Specifies the timer value to set * value - Specifies the timer value to set
* ovalue - A location in which to return the time remaining from the previous * ovalue - A location in which to return the time remaining from the
* timer setting. (ignored) * previous timer setting. (ignored)
* *
* Return Value: * Return Value:
* If the timer_settime() succeeds, a value of 0 (OK) will be returned. * If the timer_settime() succeeds, a value of 0 (OK) will be returned.
* If an error occurs, the value -1 (ERROR) will be returned, and errno set to * If an error occurs, the value -1 (ERROR) will be returned, and errno set
* indicate the error. * to indicate the error.
* *
* EINVAL - The timerid argument does not correspond to an ID returned by * EINVAL - The timerid argument does not correspond to an ID returned by
* timer_create() but not yet deleted by timer_delete(). * timer_create() but not yet deleted by timer_delete().
@@ -293,9 +296,10 @@ static void timer_timeout(int argc, wdparm_t itimer)
* *
* Assumptions: * Assumptions:
* *
********************************************************************************/ ****************************************************************************/
int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value, int timer_settime(timer_t timerid, int flags,
FAR const struct itimerspec *value,
FAR struct itimerspec *ovalue) FAR struct itimerspec *ovalue)
{ {
FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)timerid; FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)timerid;
@@ -373,7 +377,6 @@ int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value
/* Then start the watchdog */ /* Then start the watchdog */
if (delay > 0) if (delay > 0)
{ {
timer->pt_last = delay; timer->pt_last = delay;
+16 -15
View File
@@ -1,4 +1,4 @@
/******************************************************************************** /****************************************************************************
* sched/wdog/wd_gettime.c * sched/wdog/wd_gettime.c
* *
* Copyright (C) 2007, 2009, 2014-2016 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2014-2016 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Included Files * Included Files
********************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@@ -44,11 +44,11 @@
#include "wdog/wdog.h" #include "wdog/wdog.h"
/******************************************************************************** /****************************************************************************
* Public Functions * Public Functions
********************************************************************************/ ****************************************************************************/
/******************************************************************************** /****************************************************************************
* Name: wd_gettime * Name: wd_gettime
* *
* Description: * Description:
@@ -59,12 +59,11 @@
* wdog = watchdog ID * wdog = watchdog ID
* *
* Return Value: * Return Value:
* The time in system ticks remaining until the watchdog time expires. Zero * The time in system ticks remaining until the watchdog time expires.
* means either that wdog is not valid or that the wdog has already expired. * Zero means either that wdog is not valid or that the wdog has already
* expired.
* *
* Assumptions: ****************************************************************************/
*
********************************************************************************/
int wd_gettime(WDOG_ID wdog) int wd_gettime(WDOG_ID wdog)
{ {
@@ -75,14 +74,16 @@ int wd_gettime(WDOG_ID wdog)
flags = enter_critical_section(); flags = enter_critical_section();
if (wdog && WDOG_ISACTIVE(wdog)) if (wdog && WDOG_ISACTIVE(wdog))
{ {
/* Traverse the watchdog list accumulating lag times until we find the wdog /* Traverse the watchdog list accumulating lag times until we find the
* that we are looking for * wdog that we are looking for
*/ */
FAR struct wdog_s *curr; FAR struct wdog_s *curr;
int delay = 0; int delay = 0;
for (curr = (FAR struct wdog_s *)g_wdactivelist.head; curr; curr = curr->next) for (curr = (FAR struct wdog_s *)g_wdactivelist.head;
curr != NULL;
curr = curr->next)
{ {
delay += curr->lag; delay += curr->lag;
if (curr == wdog) if (curr == wdog)
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* libc/wqueue/work_process.c * sched/wqueue/work_process.c
* *
* Copyright (C) 2009-2014, 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2009-2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>