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.com/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 | /* forward declarations to avoid warnings */ |
---|
21 | void benchmark_pthread_setschedparam(void); |
---|
22 | void benchmark_pthread_getschedparam(void); |
---|
23 | void *POSIX_Init(void *argument); |
---|
24 | |
---|
25 | void benchmark_pthread_getschedparam(void) |
---|
26 | { |
---|
27 | long end_time; |
---|
28 | int status; |
---|
29 | int policy; |
---|
30 | struct sched_param param; |
---|
31 | |
---|
32 | benchmark_timer_initialize(); |
---|
33 | status = pthread_getschedparam( pthread_self(), &policy, ¶m ); |
---|
34 | end_time = benchmark_timer_read(); |
---|
35 | rtems_test_assert( status == 0 ); |
---|
36 | |
---|
37 | put_time( |
---|
38 | "pthread_getschedparam", |
---|
39 | end_time, |
---|
40 | 1, /* Only executed once */ |
---|
41 | 0, |
---|
42 | 0 |
---|
43 | ); |
---|
44 | |
---|
45 | } |
---|
46 | |
---|
47 | void benchmark_pthread_setschedparam(void) |
---|
48 | { |
---|
49 | long end_time; |
---|
50 | int status; |
---|
51 | int policy; |
---|
52 | struct sched_param param; |
---|
53 | |
---|
54 | status = pthread_getschedparam( pthread_self(), &policy, ¶m ); |
---|
55 | rtems_test_assert( status == 0 ); |
---|
56 | |
---|
57 | /* Arbitrary priority, no other threads to preempt us so it doesn't matter. */ |
---|
58 | param.sched_priority = 5; |
---|
59 | benchmark_timer_initialize(); |
---|
60 | status = pthread_setschedparam( pthread_self(), policy, ¶m ); |
---|
61 | end_time = benchmark_timer_read(); |
---|
62 | rtems_test_assert( status == 0 ); |
---|
63 | |
---|
64 | put_time( |
---|
65 | "pthread_setschedparam - no thread switch", |
---|
66 | end_time, |
---|
67 | 1, /* Only executed once */ |
---|
68 | 0, |
---|
69 | 0 |
---|
70 | ); |
---|
71 | } |
---|
72 | |
---|
73 | void *POSIX_Init( |
---|
74 | void *argument |
---|
75 | ) |
---|
76 | { |
---|
77 | |
---|
78 | puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD04 ***" ); |
---|
79 | |
---|
80 | benchmark_pthread_getschedparam(); |
---|
81 | benchmark_pthread_setschedparam(); |
---|
82 | |
---|
83 | puts( "*** END OF POSIX TIME TEST PSXTMTHREAD04 ***" ); |
---|
84 | rtems_test_exit(0); |
---|
85 | } |
---|
86 | |
---|
87 | /* configuration information */ |
---|
88 | |
---|
89 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
90 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
91 | |
---|
92 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |
---|
93 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
94 | |
---|
95 | #define CONFIGURE_INIT |
---|
96 | |
---|
97 | #include <rtems/confdefs.h> |
---|
98 | /* end of file */ |
---|