File indexing completed on 2025-05-11 08:24:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include <pthread.h>
0033 #include <timesys.h>
0034 #include <rtems/btimer.h>
0035 #include <tmacros.h>
0036 #include <sched.h>
0037 #include "test_support.h"
0038
0039 const char rtems_test_name[] = "PSXTMMUTEXATTR01";
0040
0041
0042 static void *POSIX_Init(void *argument);
0043
0044 static pthread_mutexattr_t attr;
0045
0046 static void benchmark_create_pthread_mutexattr(void)
0047 {
0048 benchmark_timer_t end_time;
0049 int status;
0050
0051 benchmark_timer_initialize();
0052 status = pthread_mutexattr_init( &attr );
0053 end_time = benchmark_timer_read();
0054 rtems_test_assert( status == 0 );
0055
0056 put_time(
0057 "pthread_mutexattr_init: only case",
0058 end_time,
0059 1,
0060 0,
0061 0
0062 );
0063
0064 }
0065
0066 static void benchmark_pthread_mutexattr_setprioceiling(void)
0067 {
0068 benchmark_timer_t end_time;
0069 int status;
0070
0071 benchmark_timer_initialize();
0072 status = pthread_mutexattr_setprioceiling( &attr, SCHED_FIFO);
0073 end_time = benchmark_timer_read();
0074 rtems_test_assert( status == 0 );
0075
0076 put_time(
0077 "pthread_mutexattr_setprioceiling: only case",
0078 end_time,
0079 1,
0080 0,
0081 0
0082 );
0083
0084 }
0085
0086 static void benchmark_pthread_mutexattr_getprioceiling(void)
0087 {
0088 benchmark_timer_t end_time;
0089 int status;
0090 int prioceiling;
0091
0092 benchmark_timer_initialize();
0093 status = pthread_mutexattr_getprioceiling( &attr, &prioceiling);
0094 end_time = benchmark_timer_read();
0095 rtems_test_assert( status == 0 );
0096 rtems_test_assert( prioceiling == SCHED_FIFO);
0097
0098 put_time(
0099 "pthread_mutexattr_getprioceiling: only case",
0100 end_time,
0101 1,
0102 0,
0103 0
0104 );
0105
0106 }
0107
0108 static void benchmark_pthread_mutexattr_setprotocol(void)
0109 {
0110 benchmark_timer_t end_time;
0111 int status;
0112
0113 benchmark_timer_initialize();
0114 status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
0115 end_time = benchmark_timer_read();
0116 rtems_test_assert( status == 0 );
0117
0118 put_time(
0119 "pthread_mutexattr_setprotocol: only case",
0120 end_time,
0121 1,
0122 0,
0123 0
0124 );
0125
0126 }
0127
0128 static void benchmark_pthread_mutexattr_getprotocol(void)
0129 {
0130 benchmark_timer_t end_time;
0131 int status;
0132 int protocol;
0133
0134 benchmark_timer_initialize();
0135 status = pthread_mutexattr_getprotocol( &attr, &protocol );
0136 end_time = benchmark_timer_read();
0137 rtems_test_assert( status == 0 );
0138 rtems_test_assert( protocol == PTHREAD_PRIO_INHERIT );
0139
0140 put_time(
0141 "pthread_mutexattr_getprotocol: only case",
0142 end_time,
0143 1,
0144 0,
0145 0
0146 );
0147
0148 }
0149
0150 static void benchmark_pthread_mutexattr_setpshared(void)
0151 {
0152 benchmark_timer_t end_time;
0153 int status;
0154
0155 benchmark_timer_initialize();
0156 status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
0157 end_time = benchmark_timer_read();
0158 rtems_test_assert( status == 0 );
0159
0160 put_time(
0161 "pthread_mutexattr_setpshared: only case",
0162 end_time,
0163 1,
0164 0,
0165 0
0166 );
0167
0168 }
0169
0170 static void benchmark_pthread_mutexattr_getpshared(void)
0171 {
0172 benchmark_timer_t end_time;
0173 int status;
0174 int pshared;
0175
0176 benchmark_timer_initialize();
0177 status = pthread_mutexattr_getpshared( &attr, &pshared );
0178 end_time = benchmark_timer_read();
0179 rtems_test_assert( status == 0 );
0180 rtems_test_assert( pshared == PTHREAD_PROCESS_PRIVATE );
0181
0182 put_time(
0183 "pthread_mutexattr_getpshared: only case",
0184 end_time,
0185 1,
0186 0,
0187 0
0188 );
0189
0190 }
0191
0192 static void benchmark_pthread_mutexattr_settype(void)
0193 {
0194 benchmark_timer_t end_time;
0195 int status;
0196
0197 benchmark_timer_initialize();
0198 status = pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_DEFAULT );
0199 end_time = benchmark_timer_read();
0200 rtems_test_assert( status == 0 );
0201
0202 put_time(
0203 "pthread_mutexattr_settype: only case",
0204 end_time,
0205 1,
0206 0,
0207 0
0208 );
0209
0210 }
0211
0212 static void benchmark_pthread_mutexattr_gettype(void)
0213 {
0214 benchmark_timer_t end_time;
0215 int status;
0216 int type;
0217
0218 benchmark_timer_initialize();
0219 status = pthread_mutexattr_gettype( &attr, &type );
0220 end_time = benchmark_timer_read();
0221 rtems_test_assert( status == 0 );
0222 rtems_test_assert( type == PTHREAD_MUTEX_DEFAULT );
0223
0224 put_time(
0225 "pthread_mutexattr_gettype: only case",
0226 end_time,
0227 1,
0228 0,
0229 0
0230 );
0231
0232 }
0233
0234 static void benchmark_destroy_pthread_mutexattr(void)
0235 {
0236 benchmark_timer_t end_time;
0237 int status;
0238
0239 benchmark_timer_initialize();
0240 status = pthread_mutexattr_destroy( &attr );
0241 end_time = benchmark_timer_read();
0242 rtems_test_assert( status == 0 );
0243
0244 put_time(
0245 "pthread_mutexattr_destroy: only case",
0246 end_time,
0247 1,
0248 0,
0249 0
0250 );
0251
0252 }
0253
0254 void *POSIX_Init(
0255 void *argument
0256 )
0257 {
0258
0259 TEST_BEGIN();
0260
0261 benchmark_create_pthread_mutexattr();
0262 benchmark_pthread_mutexattr_setprioceiling();
0263 benchmark_pthread_mutexattr_getprioceiling();
0264 benchmark_pthread_mutexattr_setprotocol();
0265 benchmark_pthread_mutexattr_getprotocol();
0266 benchmark_pthread_mutexattr_setpshared();
0267 benchmark_pthread_mutexattr_getpshared();
0268 benchmark_pthread_mutexattr_settype();
0269 benchmark_pthread_mutexattr_gettype();
0270 benchmark_destroy_pthread_mutexattr();
0271
0272 TEST_END();
0273 rtems_test_exit(0);
0274 }
0275
0276
0277
0278 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0279 #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
0280
0281
0282 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
0283 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0284
0285 #define CONFIGURE_INIT
0286
0287 #include <rtems/confdefs.h>
0288