source: rtems/testsuites/psxtmtests/psxtmthread04/init.c @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[064820c]1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[064820c]8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <pthread.h>
16#include <sched.h>
[8fbe2e6]17#include <rtems/btimer.h>
[064820c]18#include "test_support.h"
19
[fd46711]20const char rtems_test_name[] = "PSXTMTHREAD 04";
21
[064820c]22/* forward declarations to avoid warnings */
23void benchmark_pthread_setschedparam(void);
24void benchmark_pthread_getschedparam(void);
25void *POSIX_Init(void *argument);
26
27void benchmark_pthread_getschedparam(void)
28{
[de549c3]29  uint32_t            end_time;
30  int                 status;
31  int                 policy;
32  struct sched_param  param;
[064820c]33
34  benchmark_timer_initialize();
35  status = pthread_getschedparam( pthread_self(), &policy, &param );
36  end_time = benchmark_timer_read();
37  rtems_test_assert( status == 0 );
38
39  put_time(
[50162e0]40    "pthread_getschedparam: only case",
[064820c]41    end_time,
42    1,        /* Only executed once */
43    0,
44    0
45  );
46
47}
48
49void benchmark_pthread_setschedparam(void)
50{
[de549c3]51  uint32_t            end_time;
52  int                 status;
53  int                 policy;
54  struct sched_param  param;
[064820c]55
56  status = pthread_getschedparam( pthread_self(), &policy, &param );
57  rtems_test_assert( status == 0 );
58 
59  /* Arbitrary priority, no other threads to preempt us so it doesn't matter. */
60  param.sched_priority = 5;
61  benchmark_timer_initialize();
62  status = pthread_setschedparam( pthread_self(), policy, &param );
63  end_time = benchmark_timer_read();
64  rtems_test_assert( status == 0 );
65
66  put_time(
[50162e0]67     "pthread_setschedparam: no thread switch",
[064820c]68     end_time,
69     1,       /* Only executed once */
70     0,
71     0
72  );
73}
74
75void *POSIX_Init(
76  void *argument
77)
78{
79
[fd46711]80  TEST_BEGIN();
[064820c]81
82  benchmark_pthread_getschedparam();
83  benchmark_pthread_setschedparam();
84
[fd46711]85  TEST_END();
[064820c]86  rtems_test_exit(0);
87}
88
89/* configuration information */
90
91#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
92#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
93
94#define CONFIGURE_MAXIMUM_POSIX_THREADS     1
95#define CONFIGURE_POSIX_INIT_THREAD_TABLE
96
97#define CONFIGURE_INIT
98
99#include <rtems/confdefs.h>
100/* end of file */
Note: See TracBrowser for help on using the repository browser.