1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
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 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <coverhd.h> |
---|
17 | #include <tmacros.h> |
---|
18 | #include <timesys.h> |
---|
19 | #include "test_support.h" |
---|
20 | #include <pthread.h> |
---|
21 | #include <sched.h> |
---|
22 | #include <rtems/timerdrv.h> |
---|
23 | |
---|
24 | void *Low( |
---|
25 | void *argument |
---|
26 | ) |
---|
27 | { |
---|
28 | uint32_t end_time; |
---|
29 | |
---|
30 | /* |
---|
31 | * Now we have finished the thread startup overhead, |
---|
32 | * so let other threads run. When we return, we can |
---|
33 | * finish the benchmark. |
---|
34 | */ |
---|
35 | sched_yield(); |
---|
36 | /* let other threads run */ |
---|
37 | |
---|
38 | end_time = benchmark_timer_read(); |
---|
39 | |
---|
40 | put_time( |
---|
41 | "pthread_exit", |
---|
42 | end_time, |
---|
43 | OPERATION_COUNT, |
---|
44 | 0, |
---|
45 | 0 |
---|
46 | ); |
---|
47 | |
---|
48 | puts( "*** END OF POSIX TIME TEST TM02 ***" ); |
---|
49 | rtems_test_exit( 0 ); |
---|
50 | return NULL; |
---|
51 | } |
---|
52 | |
---|
53 | void *Middle( |
---|
54 | void *argument |
---|
55 | ) |
---|
56 | { |
---|
57 | /* |
---|
58 | * Now we have finished the thread startup overhead, |
---|
59 | * so let other threads run. When we return, we can |
---|
60 | * finish the benchmark. |
---|
61 | */ |
---|
62 | sched_yield(); |
---|
63 | /* let other threads run */ |
---|
64 | |
---|
65 | pthread_exit( NULL ); |
---|
66 | return NULL; |
---|
67 | } |
---|
68 | |
---|
69 | void *POSIX_Init( |
---|
70 | void *argument |
---|
71 | ) |
---|
72 | { |
---|
73 | int i; |
---|
74 | int status; |
---|
75 | pthread_t threadId; |
---|
76 | |
---|
77 | puts( "\n\n*** POSIX TIME TEST TM02 ***" ); |
---|
78 | |
---|
79 | for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) { |
---|
80 | status = pthread_create( &threadId, NULL, Middle, NULL ); |
---|
81 | rtems_test_assert( !status ); |
---|
82 | } |
---|
83 | |
---|
84 | status = pthread_create( &threadId, NULL, Low, NULL ); |
---|
85 | rtems_test_assert( !status ); |
---|
86 | |
---|
87 | /* |
---|
88 | * Let the other threads start so the thread startup overhead, |
---|
89 | * is accounted for. When we return, we can start the benchmark. |
---|
90 | */ |
---|
91 | sched_yield(); |
---|
92 | /* let other threads run */ |
---|
93 | |
---|
94 | /* start the timer and switch through all the other tasks */ |
---|
95 | benchmark_timer_initialize(); |
---|
96 | pthread_exit( NULL ); |
---|
97 | return NULL; |
---|
98 | } |
---|
99 | |
---|
100 | /* configuration information */ |
---|
101 | |
---|
102 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
103 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
104 | |
---|
105 | #define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2 |
---|
106 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
107 | |
---|
108 | #define CONFIGURE_INIT |
---|
109 | |
---|
110 | #include <rtems/confdefs.h> |
---|
111 | /* end of file */ |
---|