nuttx/sched/timer_settime.c
patacongo 30d90deedf Add the framework to support POSIX timers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@110 42af7a65-404d-4744-a932-0658087f49c3
2007-03-21 00:56:49 +00:00

137 lines
6.5 KiB
C

/********************************************************************************
* timer_settime.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************/
/********************************************************************************
* Included Files
********************************************************************************/
#include <nuttx/config.h>
#include <time.h>
#include <errno.h>
#ifndef CONFIG_DISABLE_POSIX_TIMERS
/********************************************************************************
* Definitions
********************************************************************************/
/********************************************************************************
* Private Data
********************************************************************************/
/********************************************************************************
* Public Data
********************************************************************************/
/********************************************************************************
* Private Functions
********************************************************************************/
/********************************************************************************
* Public Functions
********************************************************************************/
/********************************************************************************
* Function: timer_settime
*
* Description:
* The timer_settime() function sets the time until the next expiration of the
* timer specified by timerid from the it_value member of the value argument
* and arm the timer if the it_value member of value is non-zero. If the
* specified timer was already armed when timer_settime() is called, this call
* will reset the time until next expiration to the value specified. If the
* it_value member of value is zero, the timer will be disarmed. The effect
* of disarming or resetting a timer with pending expiration notifications is
* unspecified.
*
* If the flag TIMER_ABSTIME is not set in the argument flags, timer_settime()
* will behave as if the time until next expiration is set to be equal to the
* interval specified by the it_value member of value. That is, the timer will
* expire in it_value nanoseconds from when the call is made. If the flag
* TIMER_ABSTIME is set in the argument flags, timer_settime() will behave as
* if the time until next expiration is set to be equal to the difference between
* the absolute time specified by the it_value member of value and the current
* value of the clock associated with timerid. That is, the timer will expire
* when the clock 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.
*
* 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, a periodic (or repetitive) timer is specified.
*
* Time values that are between two consecutive non-negative integer multiples
* of the resolution of the specified timer will be rounded up to the larger
* multiple of the resolution. Quantization error will not cause the timer to
* expire earlier than the rounded time value.
*
* If the argument ovalue is not NULL, the timer_settime() function will store,
* in the location referenced by ovalue, a value representing the previous
* amount of time before the timer would have expired, or zero if the timer was
* disarmed, together with the previous timer reload value. Timers will not
* expire before their scheduled time.
*
* Parameters:
* timerid - The pre-thread timer, previously created by the call to
* timer_create(), to be be set.
* flags - Specifie characteristics of the timer (see above)
* value - Specifies the timer value to set
* ovalue - A location in which to return the time remaining from the previous
* timer setting.
*
* Return Value:
* 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
* indicate the error.
*
* EINVAL - The timerid argument does not correspond to an ID returned by
* timer_create() but not yet deleted by timer_delete().
* EINVAL - A value structure specified a nanosecond value less than zero or
* greater than or equal to 1000 million, and the it_value member of that
* structure did not specify zero seconds and nanoseconds.
*
* Assumptions:
*
********************************************************************************/
int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value,
FAR struct itimerspec *ovalue)
{
#warning "Not Implemented"
return ENOTSUP;
}
#endif /* CONFIG_DISABLE_POSIX_TIMERS */