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 <rtems/timerdrv.h> |
---|
16 | #include "test_support.h" |
---|
17 | |
---|
18 | #include <pthread.h> |
---|
19 | |
---|
20 | const char rtems_test_name[] = "PSXTMSLEEP 02"; |
---|
21 | |
---|
22 | /* forward declarations to avoid warnings */ |
---|
23 | void *POSIX_Init(void *argument); |
---|
24 | void *Middle(void *argument); |
---|
25 | void *Low(void *argument); |
---|
26 | |
---|
27 | void *Low( |
---|
28 | void *argument |
---|
29 | ) |
---|
30 | { |
---|
31 | benchmark_timer_t end_time; |
---|
32 | |
---|
33 | end_time = benchmark_timer_read(); |
---|
34 | |
---|
35 | put_time( |
---|
36 | "sleep: blocking", |
---|
37 | end_time, |
---|
38 | OPERATION_COUNT, |
---|
39 | 0, |
---|
40 | 0 |
---|
41 | ); |
---|
42 | |
---|
43 | TEST_END(); |
---|
44 | |
---|
45 | rtems_test_exit( 0 ); |
---|
46 | return NULL; |
---|
47 | } |
---|
48 | |
---|
49 | void *Middle( |
---|
50 | void *argument |
---|
51 | ) |
---|
52 | { |
---|
53 | sleep(1); |
---|
54 | return NULL; |
---|
55 | } |
---|
56 | |
---|
57 | void *POSIX_Init( |
---|
58 | void *argument |
---|
59 | ) |
---|
60 | { |
---|
61 | int i; |
---|
62 | int status; |
---|
63 | pthread_t threadId; |
---|
64 | |
---|
65 | TEST_BEGIN(); |
---|
66 | |
---|
67 | for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) { |
---|
68 | status = pthread_create( &threadId, NULL, Middle, NULL ); |
---|
69 | rtems_test_assert( !status ); |
---|
70 | } |
---|
71 | |
---|
72 | status = pthread_create( &threadId, NULL, Low, NULL ); |
---|
73 | rtems_test_assert( !status ); |
---|
74 | |
---|
75 | /* start the timer and switch through all the other tasks */ |
---|
76 | benchmark_timer_initialize(); |
---|
77 | sleep(1); |
---|
78 | return NULL; |
---|
79 | } |
---|
80 | |
---|
81 | /* configuration information */ |
---|
82 | |
---|
83 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
84 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
85 | |
---|
86 | #define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2 |
---|
87 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
88 | |
---|
89 | #define CONFIGURE_INIT |
---|
90 | |
---|
91 | #include <rtems/confdefs.h> |
---|
92 | /* end of file */ |
---|