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 | |
---|
20 | const char rtems_test_name[] = "PSXTMTHREAD 04"; |
---|
21 | |
---|
22 | /* forward declarations to avoid warnings */ |
---|
23 | void benchmark_pthread_setschedparam(void); |
---|
24 | void benchmark_pthread_getschedparam(void); |
---|
25 | void *POSIX_Init(void *argument); |
---|
26 | |
---|
27 | void 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, ¶m ); |
---|
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 | |
---|
49 | void 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, ¶m ); |
---|
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, ¶m ); |
---|
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 | |
---|
75 | void *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 */ |
---|