source: rtems/testsuites/psxtmtests/psxtmthread04/init.c @ de549c3

4.115
Last change on this file since de549c3 was de549c3, checked in by Joel Sherrill <joel.sherrill@…>, on 09/03/14 at 15:16:43

Misc psxtmtests: Use uint32_t not long for end_time to match printf() format expectations

  • Property mode set to 100644
File size: 2.2 KB
Line 
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
7 *  http://www.rtems.org/license/LICENSE.
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>
17#include <rtems/timerdrv.h>
18#include "test_support.h"
19
20const char rtems_test_name[] = "PSXTMTHREAD 04";
21
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{
29  uint32_t            end_time;
30  int                 status;
31  int                 policy;
32  struct sched_param  param;
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(
40    "pthread_getschedparam: only case",
41    end_time,
42    1,        /* Only executed once */
43    0,
44    0
45  );
46
47}
48
49void benchmark_pthread_setschedparam(void)
50{
51  uint32_t            end_time;
52  int                 status;
53  int                 policy;
54  struct sched_param  param;
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(
67     "pthread_setschedparam: no thread switch",
68     end_time,
69     1,       /* Only executed once */
70     0,
71     0
72  );
73}
74
75void *POSIX_Init(
76  void *argument
77)
78{
79
80  TEST_BEGIN();
81
82  benchmark_pthread_getschedparam();
83  benchmark_pthread_setschedparam();
84
85  TEST_END();
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.