1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
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 | pthread_mutex_t MutexId; |
---|
25 | |
---|
26 | void *Blocker( |
---|
27 | void *argument |
---|
28 | ) |
---|
29 | { |
---|
30 | (void) pthread_mutex_lock( &MutexId ); |
---|
31 | /* should never return */ |
---|
32 | rtems_test_assert( FALSE ); |
---|
33 | |
---|
34 | return NULL; |
---|
35 | } |
---|
36 | |
---|
37 | void *POSIX_Init( |
---|
38 | void *argument |
---|
39 | ) |
---|
40 | { |
---|
41 | int status; |
---|
42 | pthread_t threadId; |
---|
43 | long end_time; |
---|
44 | |
---|
45 | puts( "\n\n*** POSIX TIME TEST PSXTMMUTEX05 ***" ); |
---|
46 | |
---|
47 | status = pthread_create( &threadId, NULL, Blocker, NULL ); |
---|
48 | rtems_test_assert( status == 0 ); |
---|
49 | |
---|
50 | /* |
---|
51 | * Deliberately create the mutex after the threads. This way if the |
---|
52 | * threads do run before we intend, they will get an error. |
---|
53 | */ |
---|
54 | status = pthread_mutex_init( &MutexId, NULL ); |
---|
55 | rtems_test_assert( status == 0 ); |
---|
56 | |
---|
57 | /* |
---|
58 | * Ensure the mutex is unavailable so the other threads block. |
---|
59 | */ |
---|
60 | status = pthread_mutex_lock( &MutexId ); |
---|
61 | rtems_test_assert( status == 0 ); |
---|
62 | |
---|
63 | /* |
---|
64 | * Let the other thread start so the thread startup overhead, |
---|
65 | * is accounted for. When we return, we can start the benchmark. |
---|
66 | */ |
---|
67 | sched_yield(); |
---|
68 | /* let other thread run */ |
---|
69 | |
---|
70 | benchmark_timer_initialize(); |
---|
71 | status = pthread_mutex_unlock( &MutexId ); |
---|
72 | end_time = benchmark_timer_read(); |
---|
73 | rtems_test_assert( status == 0 ); |
---|
74 | |
---|
75 | put_time( |
---|
76 | "pthread_mutex_unlock - unblocking, no preemption", |
---|
77 | end_time, |
---|
78 | 1, |
---|
79 | 0, |
---|
80 | 0 |
---|
81 | ); |
---|
82 | |
---|
83 | puts( "*** END OF POSIX TIME TEST PSXTMMUTEX05 ***" ); |
---|
84 | rtems_test_exit( 0 ); |
---|
85 | |
---|
86 | return NULL; |
---|
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 2 |
---|
95 | #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 |
---|
96 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
97 | |
---|
98 | #define CONFIGURE_INIT |
---|
99 | |
---|
100 | #include <rtems/confdefs.h> |
---|
101 | /* end of file */ |
---|