<div dir="ltr">Looks good except for the minor issue that in the nanosleep file there is<div>a mix of (X) and ( X ) for conditionals and method invocations. Fix that</div><div>and commit.</div><div><br></div><div>FWIW while your head is in clocks, the clock attribute on condition variables</div><div>has been added but is not currently used. I don't know if it has a ticket</div><div>offhand.</div><div><br></div><div>--joel</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 9, 2016 at 10:56 AM, Gedare Bloom <span dir="ltr"><<a href="mailto:gedare@rtems.org" target="_blank">gedare@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">closes #2732<br>
---<br>
cpukit/posix/src/nanosleep.c | 55 ++++++++--<br>
testsuites/psxtests/psxhdrs/Makefile.am | 1 +<br>
testsuites/psxtests/psxhdrs/time/clock_nanosleep.c | 35 +++++++<br>
testsuites/psxtmtests/Makefile.am | 3 +<br>
testsuites/psxtmtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 3 +<br>
.../psxtmtests/psxtmclocknanosleep01/Makefile.am | 25 +++++<br>
testsuites/psxtmtests/psxtmclocknanosleep01/init.c | 59 +++++++++++<br>
.../psxtmclocknanosleep01.doc | 12 +++<br>
.../psxtmtests/psxtmclocknanosleep02/Makefile.am | 25 +++++<br>
testsuites/psxtmtests/psxtmclocknanosleep02/init.c | 109 ++++++++++++++++++++<br>
.../psxtmclocknanosleep02.doc | 10 ++<br>
.../psxtmtests/psxtmclocknanosleep03/Makefile.am | 25 +++++<br>
testsuites/psxtmtests/psxtmclocknanosleep03/init.c | 114 +++++++++++++++++++++<br>
.../psxtmclocknanosleep03.doc | 10 ++<br>
14 files changed, 477 insertions(+), 9 deletions(-)<br>
create mode 100644 testsuites/psxtests/psxhdrs/time/clock_nanosleep.c<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep01/Makefile.am<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep01/init.c<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep01/psxtmclocknanosleep01.doc<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep02/Makefile.am<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep02/init.c<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep02/psxtmclocknanosleep02.doc<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep03/Makefile.am<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep03/init.c<br>
create mode 100644 testsuites/psxtmtests/psxtmclocknanosleep03/psxtmclocknanosleep03.doc<br>
<br>
diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c<br>
index 8fc86d6..dba5b02 100644<br>
--- a/cpukit/posix/src/nanosleep.c<br>
+++ b/cpukit/posix/src/nanosleep.c<br>
@@ -8,6 +8,8 @@<br>
/*<br>
* COPYRIGHT (c) 1989-2015.<br>
* On-Line Applications Research Corporation (OAR).<br>
+ *<br>
+ * Copyright (c) 2016. Gedare Bloom.<br>
*<br>
* The license and distribution terms for this file may be<br>
* found in the file LICENSE in this distribution or at<br>
@@ -30,12 +32,10 @@<br>
static Thread_queue_Control _Nanosleep_Pseudo_queue =<br>
THREAD_QUEUE_INITIALIZER( "Nanosleep" );<br>
<br>
-/*<br>
- * 14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269<br>
- */<br>
-int nanosleep(<br>
+static inline int nanosleep_helper(<br>
const struct timespec *rqtp,<br>
- struct timespec *rmtp<br>
+ struct timespec *rmtp,<br>
+ Watchdog_Clock clock<br>
)<br>
{<br>
/*<br>
@@ -57,7 +57,7 @@ int nanosleep(<br>
* FSU and GNU/Linux pthreads shares this behavior.<br>
*/<br>
if ( !_Timespec_Is_valid( rqtp ) )<br>
- rtems_set_errno_and_return_minus_one( EINVAL );<br>
+ return EINVAL;<br>
<br>
/*<br>
* Convert the timespec delay into the appropriate number of clock ticks.<br>
@@ -93,7 +93,7 @@ int nanosleep(<br>
executing,<br>
STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,<br>
ticks,<br>
- WATCHDOG_RELATIVE,<br>
+ clock,<br>
1<br>
);<br>
<br>
@@ -110,7 +110,7 @@ int nanosleep(<br>
/*<br>
* If the user wants the time remaining, do the conversion.<br>
*/<br>
- if ( rmtp ) {<br>
+ if ( rmtp && clock == WATCHDOG_RELATIVE ) {<br>
_Timespec_From_ticks( ticks, rmtp );<br>
}<br>
<br>
@@ -122,8 +122,45 @@ int nanosleep(<br>
* If there is time remaining, then we were interrupted by a signal.<br>
*/<br>
if ( ticks )<br>
- rtems_set_errno_and_return_minus_one( EINTR );<br>
+ return EINTR;<br>
#endif<br>
<br>
return 0;<br>
}<br>
+/*<br>
+ * 14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269<br>
+ */<br>
+int nanosleep(<br>
+ const struct timespec *rqtp,<br>
+ struct timespec *rmtp<br>
+)<br>
+{<br>
+ int err = nanosleep_helper(rqtp, rmtp, WATCHDOG_RELATIVE);<br>
+ if (err) {<br>
+ rtems_set_errno_and_return_minus_one( err );<br>
+ }<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * High Resolution Sleep with Specifiable Clock, IEEE Std 1003.1, 2001<br>
+ */<br>
+int clock_nanosleep(<br>
+ clockid_t clock_id,<br>
+ int flags,<br>
+ const struct timespec *rqtp,<br>
+ struct timespec *rmtp<br>
+)<br>
+{<br>
+ int err = 0;<br>
+ if ( clock_id == CLOCK_REALTIME || clock_id == CLOCK_MONOTONIC ) {<br>
+ if ( flags & TIMER_ABSTIME ) {<br>
+ err = nanosleep_helper(rqtp, rmtp, WATCHDOG_ABSOLUTE);<br>
+ } else {<br>
+ err = nanosleep_helper(rqtp, rmtp, WATCHDOG_RELATIVE);<br>
+ }<br>
+ } else {<br>
+ err = ENOTSUP;<br>
+ }<br>
+ return err;<br>
+}<br>
diff --git a/testsuites/psxtests/psxhdrs/Makefile.am b/testsuites/psxtests/psxhdrs/Makefile.am<br>
index 3eecd84..3c60f8d 100644<br>
--- a/testsuites/psxtests/psxhdrs/Makefile.am<br>
+++ b/testsuites/psxtests/psxhdrs/Makefile.am<br>
@@ -95,6 +95,7 @@ lib_a_SOURCES += time/clock.c<br>
lib_a_SOURCES += time/clock_getcpuclockid.c<br>
lib_a_SOURCES += time/clock_getres.c<br>
lib_a_SOURCES += time/clock_gettime.c<br>
+lib_a_SOURCES += time/clock_nanosleep.c<br>
lib_a_SOURCES += time/clock_settime.c<br>
lib_a_SOURCES += time/ctime.c<br>
lib_a_SOURCES += time/ctime_r.c<br>
diff --git a/testsuites/psxtests/psxhdrs/time/clock_nanosleep.c b/testsuites/psxtests/psxhdrs/time/clock_nanosleep.c<br>
new file mode 100644<br>
index 0000000..d13100d<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxhdrs/time/clock_nanosleep.c<br>
@@ -0,0 +1,35 @@<br>
+/*<br>
+ * This test file is used to verify that the header files associated with<br>
+ * invoking this function are correct.<br>
+ *<br>
+ * Copyright (c) 2016 Gedare Bloom.<br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <time.h><br>
+<br>
+#ifndef _POSIX_TIMERS<br>
+#error "rtems is supposed to have clock_nanosleep"<br>
+#endif<br>
+<br>
+int test( void );<br>
+<br>
+int test( void )<br>
+{<br>
+ struct timespec rqtp;<br>
+ struct timespec rmtp;<br>
+ int result;<br>
+<br>
+ rqtp.tv_sec = 0;<br>
+ rqtp.tv_nsec = 0;<br>
+ result = clock_nanosleep( CLOCK_REALTIME, 0, &rqtp, &rmtp );<br>
+<br>
+ return result;<br>
+}<br>
diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am<br>
index c4276a4..e7e079a 100644<br>
--- a/testsuites/psxtmtests/Makefile.am<br>
+++ b/testsuites/psxtmtests/Makefile.am<br>
@@ -7,6 +7,9 @@ SUBDIRS += psxtmbarrier01<br>
SUBDIRS += psxtmbarrier02<br>
SUBDIRS += psxtmbarrier03<br>
SUBDIRS += psxtmbarrier04<br>
+SUBDIRS += psxtmclocknanosleep01<br>
+SUBDIRS += psxtmclocknanosleep02<br>
+SUBDIRS += psxtmclocknanosleep03<br>
SUBDIRS += psxtmcond01<br>
SUBDIRS += psxtmcond02<br>
SUBDIRS += psxtmcond03<br>
diff --git a/testsuites/psxtmtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/testsuites/psxtmtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 13cf945..b3ab540 100644<br>
--- a/testsuites/psxtmtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/testsuites/psxtmtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -81,6 +81,9 @@ psxtmbarrier01/Makefile<br>
psxtmbarrier02/Makefile<br>
psxtmbarrier03/Makefile<br>
psxtmbarrier04/Makefile<br>
+psxtmclocknanosleep01/Makefile<br>
+psxtmclocknanosleep02/Makefile<br>
+psxtmclocknanosleep03/Makefile<br>
psxtmcond01/Makefile<br>
psxtmcond02/Makefile<br>
psxtmcond03/Makefile<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep01/Makefile.am b/testsuites/psxtmtests/psxtmclocknanosleep01/Makefile.am<br>
new file mode 100644<br>
index 0000000..2476b6b<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep01/Makefile.am<br>
@@ -0,0 +1,25 @@<br>
+<br>
+rtems_tests_PROGRAMS = psxtmclocknanosleep01<br>
+psxtmclocknanosleep01_SOURCES = init.c ../../tmtests/include/timesys.h \<br>
+ ../../support/src/tmtests_empty_function.c \<br>
+ ../../support/src/tmtests_support.c<br>
+<br>
+dist_rtems_tests_DATA = psxtmclocknanosleep01.doc<br>
+<br>
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg<br>
+include $(top_srcdir)/../automake/<a href="http://compile.am" rel="noreferrer" target="_blank">compile.am</a><br>
+include $(top_srcdir)/../automake/<a href="http://leaf.am" rel="noreferrer" target="_blank">leaf.am</a><br>
+<br>
+OPERATION_COUNT = @OPERATION_COUNT@<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include<br>
+AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT)<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include<br>
+<br>
+LINK_OBJS = $(psxtmclocknanosleep01_OBJECTS)<br>
+LINK_LIBS = $(psxtmclocknanosleep01_LDLIBS)<br>
+<br>
+psxtmclocknanosleep01$(EXEEXT): $(psxtmclocknanosleep01_OBJECTS) $(psxtmclocknanosleep01_DEPENDENCIES)<br>
+ @rm -f psxtmclocknanosleep01$(EXEEXT)<br>
+ $(make-exe)<br>
+<br>
+include $(top_srcdir)/../automake/<a href="http://local.am" rel="noreferrer" target="_blank">local.am</a><br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep01/init.c b/testsuites/psxtmtests/psxtmclocknanosleep01/init.c<br>
new file mode 100644<br>
index 0000000..86c1f5f<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep01/init.c<br>
@@ -0,0 +1,59 @@<br>
+/*<br>
+ * COPYRIGHT (c) 1989-2013.<br>
+ * On-Line Applications Research Corporation (OAR).<br>
+ *<br>
+ * Copyright (c) 2016. Gedare Bloom.<br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <timesys.h><br>
+#include <rtems/btimer.h><br>
+#include "test_support.h"<br>
+<br>
+const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 01";<br>
+<br>
+/* forward declarations to avoid warnings */<br>
+void *POSIX_Init(void *argument);<br>
+<br>
+void *POSIX_Init(<br>
+ void *argument<br>
+)<br>
+{<br>
+ benchmark_timer_t end_time;<br>
+ struct timespec sleepTime;<br>
+<br>
+ sleepTime.tv_sec = 0;<br>
+ sleepTime.tv_nsec = 0;<br>
+<br>
+ TEST_BEGIN();<br>
+<br>
+ benchmark_timer_initialize();<br>
+ clock_nanosleep( CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL );<br>
+ end_time = benchmark_timer_read();<br>
+<br>
+ put_time( "nanosleep: yield", end_time, 1, 0, 0 );<br>
+<br>
+ TEST_END();<br>
+<br>
+ rtems_test_exit(0);<br>
+}<br>
+<br>
+/* configuration information */<br>
+<br>
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER<br>
+<br>
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1<br>
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE<br>
+<br>
+#define CONFIGURE_INIT<br>
+<br>
+#include <rtems/confdefs.h><br>
+/* end of file */<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep01/psxtmclocknanosleep01.doc b/testsuites/psxtmtests/psxtmclocknanosleep01/psxtmclocknanosleep01.doc<br>
new file mode 100644<br>
index 0000000..67370cf<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep01/psxtmclocknanosleep01.doc<br>
@@ -0,0 +1,12 @@<br>
+# Copyright 2016. Gedare Bloom.<br>
+#<br>
+# The license and distribution terms for this file may be<br>
+# found in the file LICENSE in this distribution or at<br>
+# <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+#<br>
+<br>
+This test benchmarks the following operations:<br>
+<br>
++ Benchmark a call to clock_nanosleep() which yields<br>
+<br>
+<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep02/Makefile.am b/testsuites/psxtmtests/psxtmclocknanosleep02/Makefile.am<br>
new file mode 100644<br>
index 0000000..6e651eb<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep02/Makefile.am<br>
@@ -0,0 +1,25 @@<br>
+<br>
+rtems_tests_PROGRAMS = psxtmclocknanosleep02<br>
+psxtmclocknanosleep02_SOURCES = init.c ../../tmtests/include/timesys.h \<br>
+ ../../support/src/tmtests_empty_function.c \<br>
+ ../../support/src/tmtests_support.c<br>
+<br>
+dist_rtems_tests_DATA = psxtmclocknanosleep02.doc<br>
+<br>
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg<br>
+include $(top_srcdir)/../automake/<a href="http://compile.am" rel="noreferrer" target="_blank">compile.am</a><br>
+include $(top_srcdir)/../automake/<a href="http://leaf.am" rel="noreferrer" target="_blank">leaf.am</a><br>
+<br>
+OPERATION_COUNT = @OPERATION_COUNT@<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include<br>
+AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT)<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include<br>
+<br>
+LINK_OBJS = $(psxtmclocknanosleep02_OBJECTS)<br>
+LINK_LIBS = $(psxtmclocknanosleep02_LDLIBS)<br>
+<br>
+psxtmclocknanosleep02$(EXEEXT): $(psxtmclocknanosleep02_OBJECTS) $(psxtmclocknanosleep02_DEPENDENCIES)<br>
+ @rm -f psxtmclocknanosleep02$(EXEEXT)<br>
+ $(make-exe)<br>
+<br>
+include $(top_srcdir)/../automake/<a href="http://local.am" rel="noreferrer" target="_blank">local.am</a><br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep02/init.c b/testsuites/psxtmtests/psxtmclocknanosleep02/init.c<br>
new file mode 100644<br>
index 0000000..b35a82b<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep02/init.c<br>
@@ -0,0 +1,109 @@<br>
+/*<br>
+ * COPYRIGHT (c) 1989-2013.<br>
+ * On-Line Applications Research Corporation (OAR).<br>
+ *<br>
+ * Copyright (c) 2016. Gedare Bloom.<br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <timesys.h><br>
+#include <rtems/btimer.h><br>
+#include "test_support.h"<br>
+<br>
+#include <pthread.h><br>
+<br>
+const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 02";<br>
+<br>
+/* forward declarations to avoid warnings */<br>
+void *POSIX_Init(void *argument);<br>
+void *Middle(void *argument);<br>
+void *Low(void *argument);<br>
+<br>
+void *Low(<br>
+ void *argument<br>
+)<br>
+{<br>
+ benchmark_timer_t end_time;<br>
+<br>
+ end_time = benchmark_timer_read();<br>
+<br>
+ put_time(<br>
+ "clock_nanosleep: blocking",<br>
+ end_time,<br>
+ OPERATION_COUNT,<br>
+ 0,<br>
+ 0<br>
+ );<br>
+<br>
+ TEST_END();<br>
+<br>
+ rtems_test_exit( 0 );<br>
+ return NULL;<br>
+}<br>
+<br>
+void *Middle(<br>
+ void *argument<br>
+)<br>
+{<br>
+ /* calling nanosleep */<br>
+ struct timespec sleepTime;<br>
+ sleepTime.tv_sec = 0;<br>
+ sleepTime.tv_nsec = 1;<br>
+<br>
+ clock_nanosleep(CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+void *POSIX_Init(<br>
+ void *argument<br>
+)<br>
+{<br>
+ int i;<br>
+ int status;<br>
+ pthread_t threadId;<br>
+ struct timespec sleepTime;<br>
+ struct timespec remainder;<br>
+<br>
+ sleepTime.tv_sec = 0;<br>
+ sleepTime.tv_nsec = 1;<br>
+ remainder.tv_sec = 0;<br>
+ remainder.tv_nsec = 0;<br>
+<br>
+ TEST_BEGIN();<br>
+<br>
+ for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {<br>
+ status = pthread_create( &threadId, NULL, Middle, NULL );<br>
+ rtems_test_assert( !status );<br>
+ }<br>
+<br>
+ status = pthread_create( &threadId, NULL, Low, NULL );<br>
+ rtems_test_assert( !status );<br>
+<br>
+ /* start the timer and switch through all the other tasks */<br>
+ benchmark_timer_initialize();<br>
+ /* calling clock_nanosleep*/<br>
+ clock_nanosleep(CLOCK_REALTIME, 0, &sleepTime, &remainder);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+/* configuration information */<br>
+<br>
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER<br>
+<br>
+#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2<br>
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE<br>
+<br>
+#define CONFIGURE_INIT<br>
+<br>
+#include <rtems/confdefs.h><br>
+ /* end of file */<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep02/psxtmclocknanosleep02.doc b/testsuites/psxtmtests/psxtmclocknanosleep02/psxtmclocknanosleep02.doc<br>
new file mode 100644<br>
index 0000000..4724ae5<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep02/psxtmclocknanosleep02.doc<br>
@@ -0,0 +1,10 @@<br>
+# Copyright (c) 2016. Gedare Bloom<br>
+#<br>
+# The license and distribution terms for this file may be<br>
+# found in the file LICENSE in this distribution or at<br>
+# <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+#<br>
+<br>
+This test benchmarks the following operations:<br>
+<br>
++ clock_nanosleep - blocking<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep03/Makefile.am b/testsuites/psxtmtests/psxtmclocknanosleep03/Makefile.am<br>
new file mode 100644<br>
index 0000000..1c8fb55<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep03/Makefile.am<br>
@@ -0,0 +1,25 @@<br>
+<br>
+rtems_tests_PROGRAMS = psxtmclocknanosleep03<br>
+psxtmclocknanosleep03_SOURCES = init.c ../../tmtests/include/timesys.h \<br>
+ ../../support/src/tmtests_empty_function.c \<br>
+ ../../support/src/tmtests_support.c<br>
+<br>
+dist_rtems_tests_DATA = psxtmclocknanosleep03.doc<br>
+<br>
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg<br>
+include $(top_srcdir)/../automake/<a href="http://compile.am" rel="noreferrer" target="_blank">compile.am</a><br>
+include $(top_srcdir)/../automake/<a href="http://leaf.am" rel="noreferrer" target="_blank">leaf.am</a><br>
+<br>
+OPERATION_COUNT = @OPERATION_COUNT@<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include<br>
+AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT)<br>
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include<br>
+<br>
+LINK_OBJS = $(psxtmclocknanosleep03_OBJECTS)<br>
+LINK_LIBS = $(psxtmclocknanosleep03_LDLIBS)<br>
+<br>
+psxtmclocknanosleep03$(EXEEXT): $(psxtmclocknanosleep03_OBJECTS) $(psxtmclocknanosleep03_DEPENDENCIES)<br>
+ @rm -f psxtmclocknanosleep03$(EXEEXT)<br>
+ $(make-exe)<br>
+<br>
+include $(top_srcdir)/../automake/<a href="http://local.am" rel="noreferrer" target="_blank">local.am</a><br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep03/init.c b/testsuites/psxtmtests/psxtmclocknanosleep03/init.c<br>
new file mode 100644<br>
index 0000000..ccceada<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep03/init.c<br>
@@ -0,0 +1,114 @@<br>
+/*<br>
+ * COPYRIGHT (c) 1989-2013.<br>
+ * On-Line Applications Research Corporation (OAR).<br>
+ *<br>
+ * Copyright (c) 2016. Gedare Bloom.<br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <timesys.h><br>
+#include <rtems/btimer.h><br>
+#include "test_support.h"<br>
+<br>
+#include <pthread.h><br>
+<br>
+const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 03";<br>
+<br>
+/* forward declarations to avoid warnings */<br>
+void *POSIX_Init(void *argument);<br>
+void *Middle(void *argument);<br>
+void *Low(void *argument);<br>
+<br>
+void *Low(<br>
+ void *argument<br>
+)<br>
+{<br>
+ benchmark_timer_t end_time;<br>
+<br>
+ end_time = benchmark_timer_read();<br>
+<br>
+ put_time(<br>
+ "clock_nanosleep: blocking",<br>
+ end_time,<br>
+ OPERATION_COUNT,<br>
+ 0,<br>
+ 0<br>
+ );<br>
+<br>
+ TEST_END();<br>
+<br>
+ rtems_test_exit( 0 );<br>
+ return NULL;<br>
+}<br>
+<br>
+void *Middle(<br>
+ void *argument<br>
+)<br>
+{<br>
+ /* calling nanosleep */<br>
+ struct timespec sleepTime;<br>
+ sleepTime.tv_sec = 0;<br>
+ sleepTime.tv_nsec = 1;<br>
+<br>
+ clock_nanosleep(<br>
+ CLOCK_REALTIME,<br>
+ TIMER_ABSTIME,<br>
+ &sleepTime,<br>
+ (struct timespec *) NULL<br>
+ );<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+void *POSIX_Init(<br>
+ void *argument<br>
+)<br>
+{<br>
+ int i;<br>
+ int status;<br>
+ pthread_t threadId;<br>
+ struct timespec sleepTime;<br>
+ struct timespec remainder;<br>
+<br>
+ sleepTime.tv_sec = 0;<br>
+ sleepTime.tv_nsec = 1;<br>
+ remainder.tv_sec = 0;<br>
+ remainder.tv_nsec = 0;<br>
+<br>
+ TEST_BEGIN();<br>
+<br>
+ for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {<br>
+ status = pthread_create( &threadId, NULL, Middle, NULL );<br>
+ rtems_test_assert( !status );<br>
+ }<br>
+<br>
+ status = pthread_create( &threadId, NULL, Low, NULL );<br>
+ rtems_test_assert( !status );<br>
+<br>
+ /* start the timer and switch through all the other tasks */<br>
+ benchmark_timer_initialize();<br>
+ /* calling clock_nanosleep*/<br>
+ clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &sleepTime, &remainder);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+/* configuration information */<br>
+<br>
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER<br>
+<br>
+#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2<br>
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE<br>
+<br>
+#define CONFIGURE_INIT<br>
+<br>
+#include <rtems/confdefs.h><br>
+ /* end of file */<br>
diff --git a/testsuites/psxtmtests/psxtmclocknanosleep03/psxtmclocknanosleep03.doc b/testsuites/psxtmtests/psxtmclocknanosleep03/psxtmclocknanosleep03.doc<br>
new file mode 100644<br>
index 0000000..8ea20f6<br>
--- /dev/null<br>
+++ b/testsuites/psxtmtests/psxtmclocknanosleep03/psxtmclocknanosleep03.doc<br>
@@ -0,0 +1,10 @@<br>
+# Copyright (c) 2016. Gedare Bloom<br>
+#<br>
+# The license and distribution terms for this file may be<br>
+# found in the file LICENSE in this distribution or at<br>
+# <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+#<br>
+<br>
+This test benchmarks the following operations:<br>
+<br>
++ clock_nanosleep - blocking with TIMER_ABSTIME<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</font></span></blockquote></div><br></div>