diff options
author | Daniel Ramirez <javamonn@gmail.com> | 2013-12-02 20:24:28 -0600 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2013-12-02 22:43:09 -0500 |
commit | 064820c8740766a4cbe698dd9dd7ec100fe3ebbb (patch) | |
tree | b04a1a593c010d3fbca87f55ffa963c55343f651 /testsuites/psxtmtests/psxtmthread04/init.c | |
parent | leon2_doxygen_1 (diff) | |
download | rtems-064820c8740766a4cbe698dd9dd7ec100fe3ebbb.tar.bz2 |
psxtmtests: added new psxtmthread04 test
Diffstat (limited to 'testsuites/psxtmtests/psxtmthread04/init.c')
-rw-r--r-- | testsuites/psxtmtests/psxtmthread04/init.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/testsuites/psxtmtests/psxtmthread04/init.c b/testsuites/psxtmtests/psxtmthread04/init.c new file mode 100644 index 0000000000..b67fca1946 --- /dev/null +++ b/testsuites/psxtmtests/psxtmthread04/init.c @@ -0,0 +1,98 @@ +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <timesys.h> +#include <pthread.h> +#include <sched.h> +#include <rtems/timerdrv.h> +#include "test_support.h" + +/* forward declarations to avoid warnings */ +void benchmark_pthread_setschedparam(void); +void benchmark_pthread_getschedparam(void); +void *POSIX_Init(void *argument); + +void benchmark_pthread_getschedparam(void) +{ + long end_time; + int status; + int policy; + struct sched_param param; + + benchmark_timer_initialize(); + status = pthread_getschedparam( pthread_self(), &policy, ¶m ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "pthread_getschedparam", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + +} + +void benchmark_pthread_setschedparam(void) +{ + long end_time; + int status; + int policy; + struct sched_param param; + + status = pthread_getschedparam( pthread_self(), &policy, ¶m ); + rtems_test_assert( status == 0 ); + + /* Arbitrary priority, no other threads to preempt us so it doesn't matter. */ + param.sched_priority = 5; + benchmark_timer_initialize(); + status = pthread_setschedparam( pthread_self(), policy, ¶m ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "pthread_setschedparam - no thread switch", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void *POSIX_Init( + void *argument +) +{ + + puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD04 ***" ); + + benchmark_pthread_getschedparam(); + benchmark_pthread_setschedparam(); + + puts( "*** END OF POSIX TIME TEST PSXTMTHREAD04 ***" ); + rtems_test_exit(0); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> +/* end of file */ |