diff --git a/ChangeLog b/ChangeLog
index cbaa96917be..e9f7b1e4ffc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,7 @@
* Eliminate compilation warnings that that crept into
recent check-ins
* Add kill()
+ * Added the framework to support POSIX timers (more to be done)
* Some Documentation updates
* Added support for the Neuros OSD / DM320
diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html
index d20f05c179b..134a46dbcd7 100644
--- a/Documentation/NuttxUserGuide.html
+++ b/Documentation/NuttxUserGuide.html
@@ -42,8 +42,10 @@ into several paragraphs that describe different groups of OS interfaces:
Paragraph 2.4 Named Message Queue Interfaces
Paragraph 2.5 Counting Semaphore Interfaces
Paragraph 2.6 Watchdog Timer Interfaces
-Paragraph 2.7 Signal Interfaces
-Paragraph 2.8 Pthread Interfaces
+Paragraph 2.7 Clocks and Timers
+Paragraph 2.8 Signal Interfaces
+Paragraph 2.9 Pthread Interfaces
+Paragraph 2.10 Filesystem Interfaces
Section 3.0, OS Data Structures:
This section documents the data structures that are used at the NuttX
@@ -1983,7 +1985,6 @@ number of parameters is determined by
-
Function Prototype:
@@ -2018,7 +2019,427 @@ VxWorks provides the following comparable interface:
-
+
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int clock_settime(clockid_t clockid, const struct timespec *tp);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+
+ Returned Values:
+
+
+ If successful, the clock_settime() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned to indicate the error:
+
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int clock_gettime(clockid_t clockid, struct timespec *tp);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+
+ Returned Values:
+
+
+ If successful, the clock_gettime() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned to indicate the error:
+
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int clock_getres(clockid_t clockid, struct timespec *res);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+
+ Returned Values:
+
+
+ If successful, the clock_getres() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned to indicate the error:
+
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ time_t mktime(struct tm *tp);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+
+ Returned Values:
+
+
+ If successful, the mktime() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned to indicate the error:
+
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ struct tm *gmtime_r(const time_t *clock, struct tm *result);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+
+ Returned Values:
+
+
+ If successful, the gmtime_r() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned to indicate the error:
+
+
+
+
+
+ #include <time.h>
+ #define localtime_r(c,r) gmtime_r(c,r)
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid);
+
+
+ Description:
+ The timer_create() function creates per-thread timer using the specified
+ clock, clock_id, as the timing base.
+ The timer_create() function returns, in
+ the location referenced by timerid, a timer ID of type timer_t used to identify
+ the timer in timer requests.
+ This timer ID is unique until the timer is deleted.
+ The particular clock, clock_id, is defined in <time.h>.
+ The timer whose ID is returned will be in a disarmed state upon return from
+ timer_create().
+
+
+ The evp argument, if non-NULL, points to a sigevent structure.
+ This structure is allocated by the called and defines the asynchronous notification to occur.
+ If the evp argument is NULL, the effect is as if the evp argument pointed to
+ a sigevent structure with the sigev_notify member having the value SIGEV_SIGNAL,
+ the sigev_signo 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
+ for per-thread timers. All implementations shall support a clock_id of
+ CLOCK_REALTIME.
+
+
+ Input Parameters:
+
+
+ clockid. Specifies the clock to use as the timing base.
+ evp. Refers to a user allocated sigevent structure that defines the
+ asynchronous notification. evp may be NULL (see above).
+ timerid. The pre-thread timer created by the call to timer_create().
+
+
+ Returned Values:
+
+
+ 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
+ other per-thread timer calls. If an error occurs, the function will return
+ a value of -1 (ERROR) and set errno to indicate the error.
+
+
+ EAGAIN. The system lacks sufficient signal queuing resources to honor the
+ request.
+ EAGAIN. The calling process has already created all of the timers it is
+ allowed by this implementation.
+ EINVAL. The specified clock ID is not defined.
+ ENOTSUP. The implementation does not support the creation of a timer attached
+ to the CPU-time clock that is specified by clock_id and associated with a
+ thread different thread invoking timer_create().
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int timer_delete(timer_t timerid);
+
+
+ Description:
+ The timer_delete() function deletes the specified timer, timerid, previously
+ created by the timer_create() function.
+ If the timer is armed when timer_delete() is called, the timer will be automatically disarmed before
+ removal.
+ The disposition of pending signals for the deleted timer is unspecified.
+
+
+ Input Parameters:
+
+
+ timerid.
+ The pre-thread timer, previously created by the call to timer_create(), to be deleted.
+
+
+ Returned Values:
+
+
+ If successful, the timer_delete() function will return zero (OK).
+ Otherwise, the function will return a value of -1 (ERROR) and set errno to indicate the error:
+
+
+ EINVAL. The timer specified timerid is not valid.
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
+ struct itimerspec *ovalue);
+
+
+ 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.
+
+
+ Input 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.
+
+
+ Returned Values:
+
+
+ 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 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.
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int timer_gettime(timer_t timerid, struct itimerspec *value);
+
+
+ Description:
+ 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
+ space pointed to by the value argument. The it_value member of this structure
+ will contain the amount of time before the timer expires, or zero if the timer
+ is disarmed. This value is returned as the interval until timer expiration,
+ even if the timer was armed with absolute time. The it_interval member of
+ value will contain the reload value last set by timer_settime().
+
+
+ Input Parameters:
+
+
+ timerid. Specifies pre-thread timer, previously created by the call to
+ timer_create(), whose remaining count will be returned.
+
+
+ Returned Values:
+
+
+ If successful, the timer_gettime() function will return zero (OK).
+ Otherwise, an non-zero error number will be returned 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().
+
+
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ int timer_getoverrun(timer_t timerid);
+
+
+ Description:
+ Only a single signal will be queued to the process for a given timer at any
+ point in time. When a timer for which a signal is still pending expires, no
+ signal will be queued, and a timer overrun will occur. When a timer
+ expiration signal is delivered to or accepted by a process, if the
+ implementation supports the Realtime Signals Extension, the
+ timer_getoverrun() function will return the timer expiration overrun count for
+ the specified timer. The overrun count returned contains the number of extra
+ timer expirations that occurred between the time the signal was generated
+ (queued) and when it was delivered or accepted, up to but not including an
+ implementation-defined maximum of DELAYTIMER_MAX. If the number of such
+ extra expirations is greater than or equal to DELAYTIMER_MAX, then the
+ overrun count will be set to DELAYTIMER_MAX. The value returned by
+ timer_getoverrun() will apply to the most recent expiration signal delivery
+ or acceptance for the timer. If no expiration signal has been delivered
+ for the timer, or if the Realtime Signals Extension is not supported, the
+ return value of timer_getoverrun() is unspecified.
+
+
+ Input Parameters:
+
+
+ timerid. Specifies pre-thread timer, previously created by the call to
+ timer_create(), whose overrun count will be returned.
+
+
+ Returned Values:
+ If the timer_getoverrun() function succeeds, it will return the timer
+ expiration overrun count as explained above. timer_getoverrun() will fail if:
+
+
+ EINVAL.
+ The timerid argument does not correspond to an ID returned by
+ timer_create() but not yet deleted by timer_delete().
+
+
+Assumptions/Limitations:
+
+POSIX Compatibility: Comparable to the POSIX
+interface of the same name.
+
+
+
+
NuttX provides signal interfaces for tasks. Signals are used to
@@ -2044,22 +2465,22 @@ VxWorks provides the following comparable interface:
The following signal handling interfaces are provided by NuttX:
-
+
Function Prototype:
@@ -2089,7 +2510,7 @@ by set such that all signals are excluded.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2119,7 +2540,7 @@ by set such that all signals are included.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2150,7 +2571,7 @@ signo to the signal set specified by set.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2181,7 +2602,7 @@ by signo from the signal set specified by set.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2214,7 +2635,7 @@ by signo is a member of the set specified by set.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2287,7 +2708,7 @@ not handled (SIG_DFL, SIG_IGN).
(all treated like SA_SIGINFO).
-
+
Function Prototype:
@@ -2337,7 +2758,7 @@ pointed to by the set input parameter.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2375,7 +2796,7 @@ is delivered more than once."
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2423,7 +2844,7 @@ function or to terminate the task." Only delivery of the signal
is required in the present implementation (even if the signal is ignored).
-
+
Function Prototype:
@@ -2455,7 +2876,7 @@ with a NULL timeout parameter. (see below).
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2521,7 +2942,7 @@ that the unblocked signal be caught; the task will be resumed even if
the unblocked signal is ignored.
-
+
Function Prototype:
@@ -2578,7 +2999,7 @@ There is no null signal in the present implementation; a zero signal will
be sent.
-
+
Function Prototype:
@@ -2633,53 +3054,53 @@ be sent.
Sending of signals to 'process groups' is not supported in NuttX.
-
+
-
+
Function Prototype:
@@ -2700,19 +3121,19 @@ for all of the individual attributes used by the implementation.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_init() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2732,19 +3153,19 @@ An attributes object can be deleted when it is no longer needed.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_destroy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2763,19 +3184,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_setschedpolicy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2794,19 +3215,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_getschedpolicy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2826,19 +3247,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_getschedpolicy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2858,19 +3279,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_getschedparam() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2890,19 +3311,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_setinheritsched() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2922,19 +3343,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_getinheritsched() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2953,19 +3374,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_setstacksize() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -2984,19 +3405,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_attr_getstacksize() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3023,19 +3444,19 @@ specify details about the kind of thread being created.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_create() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3056,19 +3477,19 @@ return value and completion status will not be requested.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_detach() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3088,19 +3509,19 @@ A thread may terminate it's own execution.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_exit() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3156,7 +3577,7 @@ the time when cancelation is re-enabled.
Thread cancellation at cancellation points is not supported.
-
+
Function Prototype:
@@ -3198,7 +3619,7 @@ No thread could be found corresponding to that specified by the given thread ID.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3217,19 +3638,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_setcancelstate() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3250,19 +3671,19 @@ the return value of the thread.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_join() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3283,19 +3704,19 @@ made available.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_yield() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3315,19 +3736,19 @@ A thread may obtain a copy of its own thread handle.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_self() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3347,19 +3768,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_getschedparam() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3379,19 +3800,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_setschedparam() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3446,7 +3867,7 @@ interface of the same name.
The present implementation ignores the destructor argument.
-
+
Function Prototype:
@@ -3496,7 +3917,7 @@ interface of the same name.
destructor function.
-
+
Function Prototype:
@@ -3537,7 +3958,7 @@ interface of the same name.
destructor function.
-
+
Function Prototype:
@@ -3569,7 +3990,7 @@ this function does nothing in the present implementation.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3588,19 +4009,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutexattr_init() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Protoype:
@@ -3619,19 +4040,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutexattr_destroy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3651,19 +4072,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutexattr_getpshared() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3683,19 +4104,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutexattr_setpshared() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3715,19 +4136,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutex_init() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3746,19 +4167,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutex_destroy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3777,19 +4198,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutex_lock() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3808,19 +4229,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutex_trylock() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3839,19 +4260,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_mutex_unlock() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3870,19 +4291,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_condattr_init() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3901,19 +4322,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_condattr_destroy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3932,19 +4353,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_init() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3963,19 +4384,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_destroy() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -3994,19 +4415,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_broadcast() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -4025,19 +4446,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_signal() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -4056,19 +4477,19 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_wait() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -4088,12 +4509,12 @@ interface of the same name.
Returned Values:
-If successful, the xxx() function will return
+If successful, the pthread_cond_timedwait() function will return
zero (OK). Otherwise, an error number will be
returned to indicate the error:
Assumptions/Limitations:
@@ -4303,14 +4724,101 @@ notify a task when a message is available on a queue.
have to do some redesign.
+
+
+ The NuttX filesystem is very simple; it does not involve any block drivers or
+ particular filesystem (like FAT or EXT2 etc.).
+ The NuttX filesystem simply supports a set a filesystem APIs
+ (open(), close(), read(), write, etc.)
+ and a registration mechanism that allows devices drivers to a associated with nodes
+ in a file-system-like name space.
+
+
+
+
+ #include <fcntl.h>
+ int open(const char *path, int oflag, ...);
+
+
+
+ #include <unistd.h>
+ int close(int fd);
+ int dup(int fildes);
+ int dup2(int fildes1, int fildes2);
+ off_t lseek(int fd, off_t offset, int whence);
+ int read(int fd, void *buf, unsigned int nbytes);
+ int unlink(const char *path);
+ int write(int fd, const void *buf, unsigned int nbytes);
+
+
+
+
+ #include <dirent.h>
+ int closedir(DIR *dirp);
+ FAR DIR *opendir(const char *path);
+ FAR struct dirent *readdir(FAR DIR *dirp);
+ int readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result);
+ void rewinddir(FAR DIR *dirp);
+ void seekdir(FAR DIR *dirp, int loc);
+ int telldir(FAR DIR *dirp);
+
+
+
+
+ #include <stdio.h>
+ int fclose(FILE *stream);
+ int fflush(FILE *stream);
+ int feof(FILE *stream);
+ int ferror(FILE *stream);
+ int fgetc(FILE *stream);
+ char *fgets(char *s, int n, FILE *stream);
+ FILE *fopen(const char *path, const char *type);
+ int fprintf(FILE *stream, const char *format, ...);
+ int fputc(int c, FILE *stream);
+ int fputs(const char *s, FILE *stream);
+ size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream);
+ int fseek(FILE *stream, long int offset, int whence);
+ size_t fwrite(const void *ptr, size_t size, size_t n_items, FILE *stream);
+ char *gets(char *s);
+
+ int printf(const char *format, ...);
+ int puts(const char *s);
+ int rename(const char *source, const char *target);
+ int sprintf(char *dest, const char *format, ...);
+ int ungetc(int c, FILE *stream);
+ int vprintf(const char *s, va_list ap);
+ int vfprintf(FILE *stream, const char *s, va_list ap);
+ int vsprintf(char *buf, const char *s, va_list ap);
+
+ int chdir(const char *path);
+ FILE *fdopen(int fd, const char *type);
+ int fstat(int fd, FAR struct stat *buf);
+ char *getcwd(FAR char *buf, size_t size);
+ int ioctl(int fd, int req, unsigned long arg);
+ int mkdir(const char *path, mode_t mode);
+ int rmdir(const char *path);
+ int stat(const char *path, FAR struct stat *buf);
+ int statfs(const char *path, FAR struct statfs *buf);
+
+
- - Data structures
+
- clock_getres
+ - clock_gettime
+ - Clocks
+ - clock_settime
+ - Data structures
+ - Directory operations
+ - Driver operations
- exit
+ - Filesystem interfaces
- getpid
+ - gmtime_r
- Introduction
- kill
+ - localtime_r
- Named Message Queue Interfaces
+
- mktime
- mq_close
- mq_getattr
- mq_notify
@@ -4398,6 +4906,7 @@ notify a task when a message is available on a queue.
- sigsuspend
- sigtimedwait
- sigwaitinfo
+ - Standard I/O
- task_activate
- Task Control Interfaces
- task_create
@@ -4406,6 +4915,12 @@ notify a task when a message is available on a queue.
- task_restart
- Task Scheduling Interfaces
- Task Switching Interfaces
+
- timer_create
+ - timer_delete
+ - timer_getoverrun
+ - timer_gettime
+ - Timers
+ - timer_settime
- Watchdog Timer Interfaces
- wd_cancel
- wd_create
diff --git a/include/time.h b/include/time.h
index 4ae94356549..5174d69b940 100644
--- a/include/time.h
+++ b/include/time.h
@@ -62,13 +62,17 @@
#define CLOCK_REALTIME 0
#define CLOCK_ABSTIME
+/* This is a flag that may be passed to the timer_settime() function */
+
+#define TIMER_ABSTIME 1
+
/********************************************************************************
* Global Type Declarations
********************************************************************************/
-typedef uint32 time_t;
-typedef ubyte clockid_t;
-typedef ubyte timer_t;
+typedef ubyte time_t;
+typedef ubyte clockid_t;
+typedef ubyte timer_t;
struct timespec
{
@@ -135,11 +139,11 @@ EXTERN time_t mktime(struct tm *tp);
EXTERN struct tm *gmtime_r(const time_t *clock, struct tm *result);
#define localtime_r(c,r) gmtime_r(c,r)
-EXTERN int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid);
+EXTERN int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timerid);
EXTERN int timer_delete(timer_t timerid);
-EXTERN int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
- struct itimerspec *ovalue);
-EXTERN int timer_gettime(timer_t timerid, struct itimerspec *value);
+EXTERN int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value,
+ FAR struct itimerspec *ovalue);
+EXTERN int timer_gettime(timer_t timerid, FAR struct itimerspec *value);
EXTERN int timer_getoverrun(timer_t timerid);
#undef EXTERN
diff --git a/sched/Makefile b/sched/Makefile
index de803739018..4679a846d66 100644
--- a/sched/Makefile
+++ b/sched/Makefile
@@ -99,10 +99,13 @@ SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\
sem_open.c sem_close.c sem_unlink.c \
sem_wait.c sem_trywait.c sem_post.c sem_getvalue.c \
sem_waitirq.c sem_findnamed.c
+ifneq ($(CONFIG_DISABLE_POSIX_TIMERSA),y)
+TIMERS_SRCS = timer_create.c timer_delete.c timer_getoverrun.c timer_gettime.c timer_settime.c
+endif
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \
- $(SEM_SRCS) $(IRQ_SRCS)
+ $(SEM_SRCS) $(TIMER_SRCS) $(IRQ_SRCS)
ifneq ($(CONFIG_DISABLE_CLOCK),y)
CSRCS += $(CLOCK_SRCS)
endif
diff --git a/sched/timer_create.c b/sched/timer_create.c
new file mode 100644
index 00000000000..b86d38d6dda
--- /dev/null
+++ b/sched/timer_create.c
@@ -0,0 +1,120 @@
+/********************************************************************************
+ * timer_create.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+#include
+
+#ifdef CONFIG_POSIX_TIMERS
+
+/********************************************************************************
+ * Definitions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Function: timer_create
+ *
+ * Description:
+ * The timer_create() function creates per-thread timer using the specified
+ * clock, clock_id, as the timing base. The timer_create() function returns, in
+ * the location referenced by timerid, a timer ID of type timer_t used to identify
+ * the timer in timer requests. This timer ID is unique until the timer is
+ * deleted. The particular clock, clock_id, is defined in . The timer
+ * whose ID is returned will be in a disarmed state upon return from
+ * timer_create().
+ *
+ * The evp argument, if non-NULL, points to a sigevent structure. This structure
+ * is allocated by the called and defines the asynchronous notification to occur.
+ * If the evp argument is NULL, the effect is as if the evp argument pointed to
+ * a sigevent structure with the sigev_notify member having the value SIGEV_SIGNAL,
+ * the sigev_signo 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
+ * for per-thread timers. All implementations shall support a clock_id of
+ * CLOCK_REALTIME.
+ *
+ * Parameters:
+ * clockid - Specifies the clock to use as the timing base.
+ * evp - Refers to a user allocated sigevent structure that defines the
+ * asynchronous notification. evp may be NULL (see above).
+ * timerid - The pre-thread timer created by the call to timer_create().
+ *
+ * Return Value:
+ * 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
+ * other per-thread timer calls. If an error occurs, the function will return
+ * a value of -1 (ERROR) and set errno to indicate the error.
+ *
+ * EAGAIN - The system lacks sufficient signal queuing resources to honor the
+ * request.
+ * EAGAIN - The calling process has already created all of the timers it is
+ * allowed by this implementation.
+ * EINVAL - The specified clock ID is not defined.
+ * ENOTSUP - The implementation does not support the creation of a timer attached
+ * to the CPU-time clock that is specified by clock_id and associated with a
+ * thread different thread invoking timer_create().
+ *
+ * Assumptions:
+ *
+ ********************************************************************************/
+
+int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timerid)
+{
+#warning "Not Implemented"
+ return ENOTSUP;
+}
+
+#endif /* CONFIG_POSIX_TIMERS */
diff --git a/sched/timer_delete.c b/sched/timer_delete.c
new file mode 100644
index 00000000000..4dc97a9bdeb
--- /dev/null
+++ b/sched/timer_delete.c
@@ -0,0 +1,95 @@
+/********************************************************************************
+ * timer_delete.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+#include
+
+#ifndef CONFIG_DISABLE_POSIX_TIMERS
+
+/********************************************************************************
+ * Definitions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Function: timer_delete
+ *
+ * Description:
+ * The timer_delete() function deletes the specified timer, timerid, previously
+ * created by the timer_create() function. If the timer is armed when
+ * timer_delete() is called, the timer will be automatically disarmed before
+ * removal. The disposition of pending signals for the deleted timer is unspecified.
+ *
+ * Parameters:
+ * timerid - The pre-thread timer, previously created by the call to
+ * timer_create(), to be deleted.
+ *
+ * Return Value:
+ * If the call succeeds, timer_create() will return 0 (OK). Otherwise, the
+ * function will return a value of -1 (ERROR) and set errno to indicate the error.
+ *
+ * EINVAL - The timer specified timerid is not valid.
+ *
+ * Assumptions:
+ *
+ ********************************************************************************/
+
+int timer_delete(timer_t timerid)
+{
+#warning "Not Implemented"
+ return ENOTSUP;
+}
+
+#endif /* CONFIG_DISABLE_POSIX_TIMERS */
diff --git a/sched/timer_getoverrun.c b/sched/timer_getoverrun.c
new file mode 100644
index 00000000000..8dbd8da6288
--- /dev/null
+++ b/sched/timer_getoverrun.c
@@ -0,0 +1,108 @@
+/********************************************************************************
+ * timer_getoverrun.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+#include
+
+#ifndef CONFIG_DISABLE_POSIX_TIMERS
+
+/********************************************************************************
+ * Definitions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Function: timer_getoverrun
+ *
+ * Description:
+ * Only a single signal will be queued to the process for a given timer at any
+ * point in time. When a timer for which a signal is still pending expires, no
+ * signal will be queued, and a timer overrun will occur. When a timer
+ * expiration signal is delivered to or accepted by a process, if the
+ * implementation supports the Realtime Signals Extension, the
+ * timer_getoverrun() function will return the timer expiration overrun count for
+ * the specified timer. The overrun count returned contains the number of extra
+ * timer expirations that occurred between the time the signal was generated
+ * (queued) and when it was delivered or accepted, up to but not including an
+ * implementation-defined maximum of DELAYTIMER_MAX. If the number of such
+ * extra expirations is greater than or equal to DELAYTIMER_MAX, then the
+ * overrun count will be set to DELAYTIMER_MAX. The value returned by
+ * timer_getoverrun() will apply to the most recent expiration signal delivery
+ * or acceptance for the timer. If no expiration signal has been delivered
+ * for the timer, or if the Realtime Signals Extension is not supported, the
+ * return value of timer_getoverrun() is unspecified.
+ *
+ * Parameters:
+ * timerid - The pre-thread timer, previously created by the call to
+ * timer_create(), whose overrun count will be returned..
+ *
+ * Return Value:
+ * If the timer_getoverrun() function succeeds, it will return the timer
+ * expiration overrun count as explained above. timer_getoverrun() will fail if:
+ *
+ * EINVAL - The timerid argument does not correspond to an ID returned by
+ * timer_create() but not yet deleted by timer_delete().
+ *
+ * Assumptions:
+ *
+ ********************************************************************************/
+
+int timer_getoverrun(timer_t timerid)
+{
+#warning "Not Implemented"
+ return ENOTSUP;
+}
+
+#endif /* CONFIG_DISABLE_POSIX_TIMERS */
diff --git a/sched/timer_gettime.c b/sched/timer_gettime.c
new file mode 100644
index 00000000000..948c6043cf1
--- /dev/null
+++ b/sched/timer_gettime.c
@@ -0,0 +1,100 @@
+/********************************************************************************
+ * timer_gettime.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+#include
+
+#ifndef CONFIG_DISABLE_POSIX_TIMERS
+
+/********************************************************************************
+ * Definitions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Data
+ ********************************************************************************/
+
+/********************************************************************************
+ * Private Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Public Functions
+ ********************************************************************************/
+
+/********************************************************************************
+ * Function: timer_gettime
+ *
+ * Description:
+ * 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
+ * space pointed to by the value argument. The it_value member of this structure
+ * will contain the amount of time before the timer expires, or zero if the timer
+ * is disarmed. This value is returned as the interval until timer expiration,
+ * even if the timer was armed with absolute time. The it_interval member of
+ * value will contain the reload value last set by timer_settime().
+ *
+ * Parameters:
+ * timerid - The pre-thread timer, previously created by the call to
+ * timer_create(), whose remaining time count will be returned..
+ *
+ * Return Value:
+ * 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
+ * indicate the error.
+ *
+ * EINVAL - The timerid argument does not correspond to an ID returned by
+ * timer_create() but not yet deleted by timer_delete().
+ *
+ * Assumptions:
+ *
+ ********************************************************************************/
+
+int timer_gettime(timer_t timerid, FAR struct itimerspec *value)
+{
+#warning "Not Implemented"
+ return ENOTSUP;
+}
+
+#endif /* CONFIG_DISABLE_POSIX_TIMERS */
diff --git a/sched/timer_settime.c b/sched/timer_settime.c
new file mode 100644
index 00000000000..8df4c7e326b
--- /dev/null
+++ b/sched/timer_settime.c
@@ -0,0 +1,136 @@
+/********************************************************************************
+ * timer_settime.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+#include
+
+#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 */