[1b4f2b30] | 1 | /* |
---|
[2e7e636f] | 2 | * COPYRIGHT (c) 1989-2009. |
---|
[870f2976] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
[98e4ebf5] | 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 7 | * http://www.rtems.org/license/LICENSE. |
---|
[870f2976] | 8 | */ |
---|
| 9 | |
---|
[cafefbf] | 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[6c2434a8] | 14 | #include <pthread.h> |
---|
| 15 | #include <sched.h> |
---|
| 16 | |
---|
[870f2976] | 17 | #define CONFIGURE_INIT |
---|
| 18 | #include "system.h" |
---|
| 19 | #include <errno.h> |
---|
[01618ccc] | 20 | #include "tmacros.h" |
---|
[4562dd8] | 21 | #include "pritime.h" |
---|
[870f2976] | 22 | |
---|
[698c2e50] | 23 | const char rtems_test_name[] = "PSX 7"; |
---|
| 24 | |
---|
[2e7e636f] | 25 | void print_schedparam( |
---|
| 26 | char *prefix, |
---|
| 27 | struct sched_param *schedparam |
---|
| 28 | ); |
---|
| 29 | |
---|
[c123a084] | 30 | void print_schedparam( |
---|
| 31 | char *prefix, |
---|
| 32 | struct sched_param *schedparam |
---|
| 33 | ) |
---|
| 34 | { |
---|
[1b4f2b30] | 35 | printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority ); |
---|
[c123a084] | 36 | #if defined(_POSIX_SPORADIC_SERVER) |
---|
[66c9ad8] | 37 | printf( "%ssched_ss_low_priority = %d\n", |
---|
| 38 | prefix, schedparam->sched_ss_low_priority ); |
---|
[4562dd8] | 39 | printf( "%ssched_ss_replenish_period = (%" PRIdtime_t ", %ld)\n", prefix, |
---|
[66c9ad8] | 40 | schedparam->sched_ss_repl_period.tv_sec, |
---|
| 41 | schedparam->sched_ss_repl_period.tv_nsec ); |
---|
[4562dd8] | 42 | printf( "%ssched_sched_ss_initial_budget = (%" PRIdtime_t ", %ld)\n", prefix, |
---|
[66c9ad8] | 43 | schedparam->sched_ss_init_budget.tv_sec, |
---|
| 44 | schedparam->sched_ss_init_budget.tv_nsec ); |
---|
[c123a084] | 45 | #else |
---|
[80bfd3a] | 46 | printf( "%s_POSIX_SPORADIC_SERVER is not defined\n", prefix ); |
---|
[c123a084] | 47 | #endif |
---|
| 48 | } |
---|
[1b4f2b30] | 49 | |
---|
[870f2976] | 50 | void *POSIX_Init( |
---|
| 51 | void *argument |
---|
| 52 | ) |
---|
| 53 | { |
---|
[c123a084] | 54 | int status; |
---|
| 55 | int scope; |
---|
| 56 | int inheritsched; |
---|
| 57 | int schedpolicy; |
---|
| 58 | size_t stacksize; |
---|
[6baf5a5] | 59 | size_t guardsize; |
---|
[c123a084] | 60 | void *stackaddr; |
---|
| 61 | int detachstate; |
---|
| 62 | struct sched_param schedparam; |
---|
| 63 | pthread_attr_t attr; |
---|
| 64 | pthread_attr_t destroyed_attr; |
---|
[870f2976] | 65 | |
---|
[698c2e50] | 66 | TEST_BEGIN(); |
---|
[870f2976] | 67 | |
---|
| 68 | /* set the time of day, and print our buffer in multiple ways */ |
---|
| 69 | |
---|
| 70 | set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); |
---|
| 71 | |
---|
| 72 | /* get id of this thread */ |
---|
| 73 | |
---|
| 74 | Init_id = pthread_self(); |
---|
[39615f4] | 75 | printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id ); |
---|
[1b4f2b30] | 76 | |
---|
[870f2976] | 77 | /* exercise init and destroy */ |
---|
| 78 | |
---|
[c9c05a0] | 79 | puts( "Init - pthread_attr_init - EINVAL (NULL attr)" ); |
---|
[870f2976] | 80 | status = pthread_attr_init( NULL ); |
---|
[01618ccc] | 81 | fatal_directive_check_status_only( status, EINVAL, "null attribute" ); |
---|
[870f2976] | 82 | |
---|
[c9c05a0] | 83 | puts( "Init - pthread_attr_init - SUCCESSFUL" ); |
---|
[870f2976] | 84 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 85 | posix_service_failed( status, "pthread_attr_init" ); |
---|
[870f2976] | 86 | |
---|
[c9c05a0] | 87 | puts( "Init - initialize and destroy an attribute - SUCCESSFUL" ); |
---|
[870f2976] | 88 | status = pthread_attr_init( &destroyed_attr ); |
---|
[01618ccc] | 89 | posix_service_failed( status, "pthread_attr_init"); |
---|
[870f2976] | 90 | |
---|
| 91 | status = pthread_attr_destroy( &destroyed_attr ); |
---|
[01618ccc] | 92 | posix_service_failed( status, "pthread_attr_destroy"); |
---|
[870f2976] | 93 | |
---|
[c9c05a0] | 94 | puts( "Init - pthread_attr_destroy - EINVAL (NULL attr)" ); |
---|
[870f2976] | 95 | status = pthread_attr_destroy( NULL ); |
---|
[01618ccc] | 96 | fatal_directive_check_status_only( status, EINVAL, "NULL attribute" ); |
---|
[870f2976] | 97 | |
---|
[c9c05a0] | 98 | puts( "Init - pthread_attr_destroy - EINVAL (not initialized)" ); |
---|
[870f2976] | 99 | status = pthread_attr_destroy( &destroyed_attr ); |
---|
[01618ccc] | 100 | fatal_directive_check_status_only( status, EINVAL, "not initialized" ); |
---|
[870f2976] | 101 | |
---|
[76de65b3] | 102 | /* check some errors in pthread_create */ |
---|
| 103 | |
---|
[c9c05a0] | 104 | puts( "Init - pthread_create - EINVAL (attr not initialized)" ); |
---|
[76de65b3] | 105 | status = pthread_create( &Task_id, &destroyed_attr, Task_1, NULL ); |
---|
[01618ccc] | 106 | fatal_directive_check_status_only( status, EINVAL, "attribute not initialized" ); |
---|
[76de65b3] | 107 | |
---|
| 108 | /* junk stack address */ |
---|
| 109 | status = pthread_attr_setstackaddr( &attr, (void *)&schedparam ); |
---|
[01618ccc] | 110 | posix_service_failed( status, "setstackaddr"); |
---|
[1b4f2b30] | 111 | |
---|
[76de65b3] | 112 | /* must go around pthread_attr_setstacksize to set a bad stack size */ |
---|
| 113 | attr.stacksize = 0; |
---|
[1b4f2b30] | 114 | |
---|
[c9c05a0] | 115 | puts( "Init - pthread_create - EINVAL (stacksize too small)" ); |
---|
[76de65b3] | 116 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
[01618ccc] | 117 | fatal_directive_check_status_only( status, EINVAL, "stacksize too small" ); |
---|
[76de65b3] | 118 | |
---|
[39b3d87] | 119 | /* reset all the fields */ |
---|
| 120 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 121 | posix_service_failed( status, "pthread_attr_init"); |
---|
[b1274bd9] | 122 | |
---|
[458bd34] | 123 | attr.stacksize = rtems_configuration_get_work_space_size() * 10; |
---|
[c9c05a0] | 124 | puts( "Init - pthread_create - EAGAIN (stacksize too large)" ); |
---|
[221bd65] | 125 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
[01618ccc] | 126 | fatal_directive_check_status_only( status, EAGAIN, "stacksize too large" ); |
---|
[221bd65] | 127 | |
---|
[76de65b3] | 128 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 129 | posix_service_failed( status, "pthread_attr_init"); |
---|
[76de65b3] | 130 | |
---|
| 131 | /* must go around pthread_attr_set routines to set a bad value */ |
---|
| 132 | attr.inheritsched = -1; |
---|
[1b4f2b30] | 133 | |
---|
[c9c05a0] | 134 | puts( "Init - pthread_create - EINVAL (invalid inherit scheduler)" ); |
---|
[76de65b3] | 135 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
[01618ccc] | 136 | fatal_directive_check_status_only( status, EINVAL, "invalid inherit scheduler" ); |
---|
[76de65b3] | 137 | |
---|
| 138 | /* check out the error case for system scope not supported */ |
---|
| 139 | |
---|
| 140 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 141 | posix_service_failed( status, " pthread_attr_init"); |
---|
| 142 | |
---|
[76de65b3] | 143 | /* must go around pthread_attr_set routines to set a bad value */ |
---|
| 144 | attr.contentionscope = PTHREAD_SCOPE_SYSTEM; |
---|
| 145 | |
---|
[c9c05a0] | 146 | puts( "Init - pthread_create - ENOTSUP (unsupported system contention scope)" ); |
---|
[76de65b3] | 147 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
[b1274bd9] | 148 | fatal_directive_check_status_only( status, ENOTSUP, |
---|
[01618ccc] | 149 | "unsupported system contention scope" ); |
---|
[76de65b3] | 150 | |
---|
| 151 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 152 | posix_service_failed( status, "pthread_attr_init"); |
---|
[76de65b3] | 153 | |
---|
| 154 | /* now check out pthread_create for inherit scheduler */ |
---|
| 155 | |
---|
| 156 | status = pthread_attr_setinheritsched( &attr, PTHREAD_INHERIT_SCHED ); |
---|
[01618ccc] | 157 | posix_service_failed( status, "pthread_attr_setinheritsched"); |
---|
[1b4f2b30] | 158 | |
---|
[c9c05a0] | 159 | puts( "Init - pthread_create - SUCCESSFUL (inherit scheduler)" ); |
---|
[76de65b3] | 160 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
[01618ccc] | 161 | posix_service_failed( status, "pthread_create"); |
---|
[76de65b3] | 162 | |
---|
| 163 | status = pthread_join( Task_id, NULL ); |
---|
[01618ccc] | 164 | posix_service_failed( status, " pthread_join"); |
---|
[76de65b3] | 165 | |
---|
| 166 | /* switch to Task_1 */ |
---|
| 167 | |
---|
[870f2976] | 168 | /* exercise get and set scope */ |
---|
| 169 | |
---|
| 170 | empty_line(); |
---|
| 171 | |
---|
[76de65b3] | 172 | status = pthread_attr_init( &attr ); |
---|
[01618ccc] | 173 | posix_service_failed( status, "pthread_attr_init"); |
---|
[76de65b3] | 174 | |
---|
[c9c05a0] | 175 | puts( "Init - pthread_attr_setscope - EINVAL (NULL attr)" ); |
---|
[870f2976] | 176 | status = pthread_attr_setscope( NULL, PTHREAD_SCOPE_PROCESS ); |
---|
[01618ccc] | 177 | fatal_directive_check_status_only( status, EINVAL , "NULL attr" ); |
---|
[870f2976] | 178 | |
---|
[c9c05a0] | 179 | puts( "Init - pthread_attr_setscope - ENOTSUP" ); |
---|
[870f2976] | 180 | status = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); |
---|
[01618ccc] | 181 | fatal_directive_check_status_only( status, ENOTSUP, "PTHREAD_SCOPE_SYSTEM" ); |
---|
[870f2976] | 182 | |
---|
[c9c05a0] | 183 | puts( "Init - pthread_attr_setscope - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 184 | status = pthread_attr_setscope( &destroyed_attr, PTHREAD_SCOPE_PROCESS ); |
---|
[01618ccc] | 185 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[870f2976] | 186 | |
---|
[c9c05a0] | 187 | puts( "Init - pthread_attr_setscope - EINVAL (invalid scope)" ); |
---|
[870f2976] | 188 | status = pthread_attr_setscope( &attr, -1 ); |
---|
[01618ccc] | 189 | fatal_directive_check_status_only( status, EINVAL, "invalid scope" ); |
---|
[870f2976] | 190 | |
---|
[c9c05a0] | 191 | puts( "Init - pthread_attr_setscope - SUCCESSFUL" ); |
---|
[870f2976] | 192 | status = pthread_attr_setscope( &attr, PTHREAD_SCOPE_PROCESS ); |
---|
[01618ccc] | 193 | posix_service_failed( status, "pthread_attr_setscope"); |
---|
[1b4f2b30] | 194 | |
---|
[c9c05a0] | 195 | puts( "Init - pthread_attr_getscope - EINVAL (NULL attr)" ); |
---|
[870f2976] | 196 | status = pthread_attr_getscope( NULL, &scope ); |
---|
[01618ccc] | 197 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 198 | |
---|
[c9c05a0] | 199 | puts( "Init - pthread_attr_getscope - EINVAL (NULL scope)" ); |
---|
[ff53a6d4] | 200 | status = pthread_attr_getscope( &attr, NULL ); |
---|
[01618ccc] | 201 | fatal_directive_check_status_only( status, EINVAL, "NULL scope" ); |
---|
[1b4f2b30] | 202 | |
---|
[c9c05a0] | 203 | puts( "Init - pthread_attr_getscope - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 204 | status = pthread_attr_getscope( &destroyed_attr, &scope ); |
---|
[01618ccc] | 205 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 206 | |
---|
[c9c05a0] | 207 | puts( "Init - pthread_attr_getscope - SUCCESSFUL" ); |
---|
[870f2976] | 208 | status = pthread_attr_getscope( &attr, &scope ); |
---|
[01618ccc] | 209 | posix_service_failed( status, "pthread_attr_getscope"); |
---|
[c9c05a0] | 210 | printf( "Init - current scope attribute = %d\n", scope ); |
---|
[870f2976] | 211 | |
---|
| 212 | /* exercise get and set inherit scheduler */ |
---|
| 213 | |
---|
| 214 | empty_line(); |
---|
| 215 | |
---|
[c9c05a0] | 216 | puts( "Init - pthread_attr_setinheritsched - EINVAL (NULL attr)" ); |
---|
[870f2976] | 217 | status = pthread_attr_setinheritsched( NULL, PTHREAD_INHERIT_SCHED ); |
---|
[01618ccc] | 218 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 219 | |
---|
[c9c05a0] | 220 | puts( "Init - pthread_attr_setinheritsched - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 221 | status = |
---|
| 222 | pthread_attr_setinheritsched( &destroyed_attr, PTHREAD_INHERIT_SCHED ); |
---|
[01618ccc] | 223 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 224 | |
---|
[c9c05a0] | 225 | puts( "Init - pthread_attr_setinheritsched - ENOTSUP (invalid inheritsched)" ); |
---|
[870f2976] | 226 | status = pthread_attr_setinheritsched( &attr, -1 ); |
---|
[01618ccc] | 227 | fatal_directive_check_status_only( status, ENOTSUP, "invalid inheritsched" ); |
---|
[1b4f2b30] | 228 | |
---|
[c9c05a0] | 229 | puts( "Init - pthread_attr_setinheritsched - SUCCESSFUL" ); |
---|
[870f2976] | 230 | status = pthread_attr_setinheritsched( &attr, PTHREAD_INHERIT_SCHED ); |
---|
[01618ccc] | 231 | posix_service_failed( status, "pthread_attr_setinheritsched"); |
---|
[1b4f2b30] | 232 | |
---|
[c9c05a0] | 233 | puts( "Init - pthread_attr_getinheritsched - EINVAL (NULL attr)" ); |
---|
[870f2976] | 234 | status = pthread_attr_getinheritsched( NULL, &inheritsched ); |
---|
[01618ccc] | 235 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 236 | |
---|
[c9c05a0] | 237 | puts( "Init - pthread_attr_getinheritsched - EINVAL (NULL inheritsched)" ); |
---|
[ac81b6ca] | 238 | status = pthread_attr_getinheritsched( &attr, NULL ); |
---|
[01618ccc] | 239 | fatal_directive_check_status_only( status, EINVAL, "NULL inheritsched" ); |
---|
[1b4f2b30] | 240 | |
---|
[c9c05a0] | 241 | puts( "Init - pthread_attr_getinheritsched - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 242 | status = pthread_attr_getinheritsched( &destroyed_attr, &inheritsched ); |
---|
[01618ccc] | 243 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 244 | |
---|
[c9c05a0] | 245 | puts( "Init - pthread_attr_getinheritsched - SUCCESSFUL" ); |
---|
[870f2976] | 246 | status = pthread_attr_getinheritsched( &attr, &inheritsched ); |
---|
[01618ccc] | 247 | posix_service_failed( status, "pthread_attr_getinheritsched"); |
---|
[c9c05a0] | 248 | printf( "Init - current inherit scheduler attribute = %d\n", inheritsched ); |
---|
[870f2976] | 249 | |
---|
| 250 | /* exercise get and set inherit scheduler */ |
---|
[1b4f2b30] | 251 | |
---|
[870f2976] | 252 | empty_line(); |
---|
[1b4f2b30] | 253 | |
---|
[c9c05a0] | 254 | puts( "Init - pthread_attr_setschedpolicy - EINVAL (NULL attr)" ); |
---|
[870f2976] | 255 | status = pthread_attr_setschedpolicy( NULL, SCHED_FIFO ); |
---|
[01618ccc] | 256 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 257 | |
---|
[c9c05a0] | 258 | puts( "Init - pthread_attr_setschedpolicy - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 259 | status = |
---|
| 260 | pthread_attr_setschedpolicy( &destroyed_attr, SCHED_OTHER ); |
---|
[01618ccc] | 261 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 262 | |
---|
[c9c05a0] | 263 | puts( "Init - pthread_attr_setschedpolicy - ENOTSUP (invalid schedpolicy)" ); |
---|
[870f2976] | 264 | status = pthread_attr_setschedpolicy( &attr, -1 ); |
---|
[01618ccc] | 265 | fatal_directive_check_status_only( status, ENOTSUP, "invalid schedpolicy" ); |
---|
[1b4f2b30] | 266 | |
---|
[c9c05a0] | 267 | puts( "Init - pthread_attr_setschedpolicy - SUCCESSFUL" ); |
---|
[870f2976] | 268 | status = pthread_attr_setschedpolicy( &attr, SCHED_RR ); |
---|
[01618ccc] | 269 | posix_service_failed( status, "pthread_attr_setschedpolicy"); |
---|
[1b4f2b30] | 270 | |
---|
[c9c05a0] | 271 | puts( "Init - pthread_attr_getschedpolicy - EINVAL (NULL attr)" ); |
---|
[870f2976] | 272 | status = pthread_attr_getschedpolicy( NULL, &schedpolicy ); |
---|
[01618ccc] | 273 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 274 | |
---|
[c9c05a0] | 275 | puts( "Init - pthread_attr_getschedpolicy - EINVAL (NULL schedpolicy)" ); |
---|
[ac81b6ca] | 276 | status = pthread_attr_getschedpolicy( &attr, NULL ); |
---|
[01618ccc] | 277 | fatal_directive_check_status_only( status, EINVAL, "NULL schedpolicy" ); |
---|
[1b4f2b30] | 278 | |
---|
[c9c05a0] | 279 | puts( "Init - pthread_attr_getschedpolicy - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 280 | status = pthread_attr_getschedpolicy( &destroyed_attr, &schedpolicy ); |
---|
[01618ccc] | 281 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 282 | |
---|
[c9c05a0] | 283 | puts( "Init - pthread_attr_getschedpolicy - SUCCESSFUL" ); |
---|
[870f2976] | 284 | status = pthread_attr_getschedpolicy( &attr, &schedpolicy ); |
---|
[01618ccc] | 285 | posix_service_failed( status, "pthread_attr_getschedpolicy"); |
---|
[c9c05a0] | 286 | printf( "Init - current scheduler policy attribute = %d\n", schedpolicy ); |
---|
[1b4f2b30] | 287 | |
---|
[870f2976] | 288 | /* exercise get and set stack size */ |
---|
[1b4f2b30] | 289 | |
---|
[870f2976] | 290 | empty_line(); |
---|
[1b4f2b30] | 291 | |
---|
[c9c05a0] | 292 | puts( "Init - pthread_attr_setstacksize - EINVAL (NULL attr)" ); |
---|
[870f2976] | 293 | status = pthread_attr_setstacksize( NULL, 0 ); |
---|
[01618ccc] | 294 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 295 | |
---|
[c9c05a0] | 296 | puts( "Init - pthread_attr_setstacksize - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 297 | status = |
---|
| 298 | pthread_attr_setstacksize( &destroyed_attr, 0 ); |
---|
[01618ccc] | 299 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 300 | |
---|
[c9c05a0] | 301 | puts( "Init - pthread_attr_setstacksize - SUCCESSFUL (low stacksize)" ); |
---|
[870f2976] | 302 | status = pthread_attr_setstacksize( &attr, 0 ); |
---|
[01618ccc] | 303 | posix_service_failed( status, "pthread_attr_setstacksize"); |
---|
[870f2976] | 304 | |
---|
[c9c05a0] | 305 | puts( "Init - pthread_attr_setstacksize - SUCCESSFUL (high stacksize)" ); |
---|
[870f2976] | 306 | status = pthread_attr_setstacksize( &attr, STACK_MINIMUM_SIZE * 2 ); |
---|
[01618ccc] | 307 | posix_service_failed( status, ""); |
---|
[1b4f2b30] | 308 | |
---|
[c9c05a0] | 309 | puts( "Init - pthread_attr_getstacksize - EINVAL (NULL attr)" ); |
---|
[870f2976] | 310 | status = pthread_attr_getstacksize( NULL, &stacksize ); |
---|
[01618ccc] | 311 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 312 | |
---|
[c9c05a0] | 313 | puts( "Init - pthread_attr_getstacksize - EINVAL (NULL stacksize)" ); |
---|
[ac81b6ca] | 314 | status = pthread_attr_getstacksize( &attr, NULL ); |
---|
[01618ccc] | 315 | fatal_directive_check_status_only( status, EINVAL, "NULL stacksize" ); |
---|
[1b4f2b30] | 316 | |
---|
[c9c05a0] | 317 | puts( "Init - pthread_attr_getstacksize - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 318 | status = pthread_attr_getstacksize( &destroyed_attr, &stacksize ); |
---|
[01618ccc] | 319 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 320 | |
---|
[c9c05a0] | 321 | puts( "Init - pthread_attr_getstacksize - SUCCESSFUL" ); |
---|
[870f2976] | 322 | status = pthread_attr_getstacksize( &attr, &stacksize ); |
---|
[01618ccc] | 323 | posix_service_failed( status, "pthread_attr_getstacksize"); |
---|
[1fbd283c] | 324 | if ( stacksize == (STACK_MINIMUM_SIZE * 2) ) |
---|
[c9c05a0] | 325 | printf( "Init - current stack size attribute is OK\n" ); |
---|
[870f2976] | 326 | |
---|
| 327 | /* exercise get and set stack address */ |
---|
| 328 | empty_line(); |
---|
[1b4f2b30] | 329 | |
---|
[c9c05a0] | 330 | puts( "Init - pthread_attr_setstackaddr - EINVAL (NULL attr)" ); |
---|
[870f2976] | 331 | status = pthread_attr_setstackaddr( NULL, NULL ); |
---|
[01618ccc] | 332 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 333 | |
---|
[c9c05a0] | 334 | puts( "Init - pthread_attr_setstackaddr - EINVAL (not initialized attr)" ); |
---|
[6baf5a5] | 335 | status = pthread_attr_setstackaddr( &destroyed_attr, NULL ); |
---|
[01618ccc] | 336 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 337 | |
---|
[c9c05a0] | 338 | puts( "Init - pthread_attr_setstackaddr - SUCCESSFUL" ); |
---|
[870f2976] | 339 | status = pthread_attr_setstackaddr( &attr, 0 ); |
---|
[01618ccc] | 340 | posix_service_failed( status, ""); |
---|
[1b4f2b30] | 341 | |
---|
[6baf5a5] | 342 | /* get stack addr */ |
---|
[c9c05a0] | 343 | puts( "Init - pthread_attr_getstackaddr - EINVAL (NULL attr)" ); |
---|
[870f2976] | 344 | status = pthread_attr_getstackaddr( NULL, &stackaddr ); |
---|
[01618ccc] | 345 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 346 | |
---|
[c9c05a0] | 347 | puts( "Init - pthread_attr_getstackaddr - EINVAL (NULL stackaddr)" ); |
---|
[ac81b6ca] | 348 | status = pthread_attr_getstackaddr( &attr, NULL ); |
---|
[01618ccc] | 349 | fatal_directive_check_status_only( status, EINVAL, "NULL stackaddr" ); |
---|
[1b4f2b30] | 350 | |
---|
[c9c05a0] | 351 | puts( "Init - pthread_attr_getstackaddr - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 352 | status = pthread_attr_getstackaddr( &destroyed_attr, &stackaddr ); |
---|
[01618ccc] | 353 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 354 | |
---|
[c9c05a0] | 355 | puts( "Init - pthread_attr_getstackaddr - SUCCESSFUL" ); |
---|
[870f2976] | 356 | status = pthread_attr_getstackaddr( &attr, &stackaddr ); |
---|
[01618ccc] | 357 | posix_service_failed( status, "pthread_attr_getstackaddr"); |
---|
[c9c05a0] | 358 | printf( "Init - current stack address attribute = %p\n", stackaddr ); |
---|
[1b4f2b30] | 359 | |
---|
[6baf5a5] | 360 | /* exercise get and set stack (as pair) */ |
---|
| 361 | empty_line(); |
---|
| 362 | |
---|
| 363 | puts( "Init - pthread_attr_setstack- EINVAL (NULL attr)" ); |
---|
| 364 | status = pthread_attr_setstack( NULL, &stackaddr, 1024 ); |
---|
| 365 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
| 366 | |
---|
| 367 | puts( "Init - pthread_attr_setstack- EINVAL (destroyed attr)" ); |
---|
| 368 | status = pthread_attr_setstack( &destroyed_attr, &stackaddr, 1024 ); |
---|
| 369 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
| 370 | |
---|
| 371 | puts( "Init - pthread_attr_setstack- SUCCESSFUL (< min stack)" ); |
---|
| 372 | status = pthread_attr_setstack( &attr, stackaddr, 0 ); |
---|
| 373 | posix_service_failed( status, "OK"); |
---|
| 374 | |
---|
| 375 | puts( "Init - pthread_attr_setstack- SUCCESSFUL (big stack)" ); |
---|
| 376 | status = pthread_attr_setstack( &attr, stackaddr, STACK_MINIMUM_SIZE * 2 ); |
---|
| 377 | posix_service_failed( status, "OK"); |
---|
| 378 | |
---|
| 379 | puts( "Init - pthread_attr_getstack- EINVAL (NULL attr)" ); |
---|
| 380 | status = pthread_attr_getstack( NULL, &stackaddr, &stacksize ); |
---|
| 381 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
| 382 | |
---|
| 383 | puts( "Init - pthread_attr_getstack- EINVAL (destroyed attr)" ); |
---|
| 384 | status = pthread_attr_getstack( &destroyed_attr, &stackaddr, &stacksize ); |
---|
| 385 | fatal_directive_check_status_only( status, EINVAL, "&destroyed attr" ); |
---|
| 386 | |
---|
| 387 | puts( "Init - pthread_attr_getstack- EINVAL (NULL stack)" ); |
---|
| 388 | status = pthread_attr_getstack( &attr, NULL, &stacksize ); |
---|
| 389 | fatal_directive_check_status_only( status, EINVAL, "&NULL stack" ); |
---|
| 390 | |
---|
| 391 | puts( "Init - pthread_attr_getstack- EINVAL (NULL stacksize)" ); |
---|
| 392 | status = pthread_attr_getstack( &attr, &stackaddr, NULL ); |
---|
| 393 | fatal_directive_check_status_only( status, EINVAL, "&NULL size" ); |
---|
| 394 | |
---|
| 395 | puts( "Init - pthread_attr_getstack- SUCCESSFUL" ); |
---|
| 396 | status = pthread_attr_getstack( &attr, &stackaddr, &stacksize ); |
---|
| 397 | posix_service_failed( status, "pthread_attr_getstack"); |
---|
| 398 | |
---|
[870f2976] | 399 | /* exercise get and set detach state */ |
---|
[6baf5a5] | 400 | empty_line(); |
---|
| 401 | |
---|
| 402 | puts( "Init - pthread_attr_setguardsize - EINVAL (NULL attr)" ); |
---|
| 403 | status = pthread_attr_setguardsize( NULL, 0 ); |
---|
| 404 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
| 405 | |
---|
| 406 | puts( "Init - pthread_attr_setguardsize - EINVAL (not initialized attr)" ); |
---|
| 407 | status = pthread_attr_setguardsize( &destroyed_attr, 0 ); |
---|
| 408 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
| 409 | |
---|
| 410 | puts( "Init - pthread_attr_setguardsize - SUCCESSFUL (low guardsize)" ); |
---|
| 411 | status = pthread_attr_setguardsize( &attr, 0 ); |
---|
| 412 | posix_service_failed( status, "pthread_attr_setguardsize"); |
---|
| 413 | |
---|
| 414 | puts( "Init - pthread_attr_setguardsize - SUCCESSFUL (high guardsize)" ); |
---|
| 415 | status = pthread_attr_setguardsize( &attr, STACK_MINIMUM_SIZE * 2 ); |
---|
| 416 | posix_service_failed( status, ""); |
---|
| 417 | |
---|
| 418 | puts( "Init - pthread_attr_getguardsize - EINVAL (NULL attr)" ); |
---|
| 419 | status = pthread_attr_getguardsize( NULL, &guardsize ); |
---|
| 420 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 421 | |
---|
[6baf5a5] | 422 | puts( "Init - pthread_attr_getguardsize - EINVAL (NULL guardsize)" ); |
---|
| 423 | status = pthread_attr_getguardsize( &attr, NULL ); |
---|
| 424 | fatal_directive_check_status_only( status, EINVAL, "NULL guardsize" ); |
---|
| 425 | |
---|
| 426 | puts( "Init - pthread_attr_getguardsize - EINVAL (not initialized attr)" ); |
---|
| 427 | status = pthread_attr_getguardsize( &destroyed_attr, &guardsize ); |
---|
| 428 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
| 429 | |
---|
| 430 | puts( "Init - pthread_attr_getguardsize - SUCCESSFUL" ); |
---|
| 431 | status = pthread_attr_getguardsize( &attr, &guardsize ); |
---|
| 432 | posix_service_failed( status, "pthread_attr_getguardsize"); |
---|
| 433 | |
---|
| 434 | /* exercise get and set detach state */ |
---|
[870f2976] | 435 | empty_line(); |
---|
[1b4f2b30] | 436 | |
---|
[c9c05a0] | 437 | puts( "Init - pthread_attr_setdetachstate - EINVAL (NULL attr)" ); |
---|
[870f2976] | 438 | status = pthread_attr_setdetachstate( NULL, PTHREAD_CREATE_DETACHED ); |
---|
[01618ccc] | 439 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 440 | |
---|
[c9c05a0] | 441 | puts( "Init - pthread_attr_setdetachstate - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 442 | status = |
---|
| 443 | pthread_attr_setdetachstate( &destroyed_attr, PTHREAD_CREATE_JOINABLE ); |
---|
[01618ccc] | 444 | fatal_directive_check_status_only( status, EINVAL, "not initialized att" ); |
---|
[1b4f2b30] | 445 | |
---|
[c9c05a0] | 446 | puts( "Init - pthread_attr_setdetachstate - EINVAL (invalid detachstate)" ); |
---|
[870f2976] | 447 | status = pthread_attr_setdetachstate( &attr, -1 ); |
---|
[01618ccc] | 448 | fatal_directive_check_status_only( status, EINVAL, "invalid detachstate" ); |
---|
[1b4f2b30] | 449 | |
---|
[c9c05a0] | 450 | puts( "Init - pthread_attr_setdetachstate - SUCCESSFUL" ); |
---|
[870f2976] | 451 | status = pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); |
---|
[01618ccc] | 452 | posix_service_failed( status, "pthread_attr_setdetachstate"); |
---|
[1b4f2b30] | 453 | |
---|
[c9c05a0] | 454 | puts( "Init - pthread_attr_getdetachstate - EINVAL (NULL attr)" ); |
---|
[870f2976] | 455 | status = pthread_attr_getdetachstate( NULL, &detachstate ); |
---|
[01618ccc] | 456 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 457 | |
---|
[c9c05a0] | 458 | puts( "Init - pthread_attr_getdetachstate - EINVAL (NULL detatchstate)" ); |
---|
[ac81b6ca] | 459 | status = pthread_attr_getdetachstate( &attr, NULL ); |
---|
[01618ccc] | 460 | fatal_directive_check_status_only( status, EINVAL, "NULL detatchstate" ); |
---|
[1b4f2b30] | 461 | |
---|
[c9c05a0] | 462 | puts( "Init - pthread_attr_getdetachstate - EINVAL (not initialized attr)" ); |
---|
[870f2976] | 463 | status = pthread_attr_getdetachstate( &destroyed_attr, &detachstate ); |
---|
[01618ccc] | 464 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 465 | |
---|
[c9c05a0] | 466 | puts( "Init - pthread_attr_getdetachstate - SUCCESSFUL" ); |
---|
[870f2976] | 467 | status = pthread_attr_getdetachstate( &attr, &detachstate ); |
---|
[01618ccc] | 468 | posix_service_failed( status, "pthread_attr_getdetachstate"); |
---|
[c9c05a0] | 469 | printf( "Init - current detach state attribute = %d\n", detachstate ); |
---|
[870f2976] | 470 | |
---|
[c123a084] | 471 | /* exercise get and set scheduling parameters */ |
---|
| 472 | |
---|
| 473 | empty_line(); |
---|
| 474 | |
---|
[c9c05a0] | 475 | puts( "Init - pthread_attr_getschedparam - SUCCESSFUL" ); |
---|
[c123a084] | 476 | status = pthread_attr_getschedparam( &attr, &schedparam ); |
---|
[01618ccc] | 477 | posix_service_failed( status, "pthread_attr_getschedparam"); |
---|
[c123a084] | 478 | |
---|
[c9c05a0] | 479 | print_schedparam( "Init - ", &schedparam ); |
---|
[c123a084] | 480 | |
---|
[c9c05a0] | 481 | puts( "Init - pthread_attr_setschedparam - EINVAL (NULL attr)" ); |
---|
[c123a084] | 482 | status = pthread_attr_setschedparam( NULL, &schedparam ); |
---|
[01618ccc] | 483 | fatal_directive_check_status_only( status, EINVAL, "NULL attr" ); |
---|
[1b4f2b30] | 484 | |
---|
[c9c05a0] | 485 | puts( "Init - pthread_attr_setschedparam - EINVAL (not initialized attr)" ); |
---|
[c123a084] | 486 | status = pthread_attr_setschedparam( &destroyed_attr, &schedparam ); |
---|
[01618ccc] | 487 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 488 | |
---|
[c9c05a0] | 489 | puts( "Init - pthread_attr_setschedparam - EINVAL (NULL schedparam)" ); |
---|
[c123a084] | 490 | status = pthread_attr_setschedparam( &attr, NULL ); |
---|
[01618ccc] | 491 | fatal_directive_check_status_only( status, EINVAL, "NULL schedparam" ); |
---|
[1b4f2b30] | 492 | |
---|
[c9c05a0] | 493 | puts( "Init - pthread_attr_setschedparam - SUCCESSFUL" ); |
---|
[c123a084] | 494 | status = pthread_attr_setschedparam( &attr, &schedparam ); |
---|
[01618ccc] | 495 | posix_service_failed( status, "pthread_attr_setschedparam"); |
---|
[1b4f2b30] | 496 | |
---|
[c9c05a0] | 497 | puts( "Init - pthread_attr_getschedparam - EINVAL (NULL attr)" ); |
---|
[c123a084] | 498 | status = pthread_attr_getschedparam( NULL, &schedparam ); |
---|
[01618ccc] | 499 | fatal_directive_check_status_only( status, EINVAL, "pthread_attr_getschedparam" ); |
---|
[1b4f2b30] | 500 | |
---|
[c9c05a0] | 501 | puts( "Init - pthread_attr_getschedparam - EINVAL (not initialized attr)" ); |
---|
[c123a084] | 502 | status = pthread_attr_getschedparam( &destroyed_attr, &schedparam ); |
---|
[01618ccc] | 503 | fatal_directive_check_status_only( status, EINVAL, "not initialized attr" ); |
---|
[1b4f2b30] | 504 | |
---|
[c9c05a0] | 505 | puts( "Init - pthread_attr_getschedparam - EINVAL (NULL schedparam)" ); |
---|
[c123a084] | 506 | status = pthread_attr_getschedparam( &attr, NULL ); |
---|
[01618ccc] | 507 | fatal_directive_check_status_only( status, EINVAL, "NULL schedparam" ); |
---|
[1b4f2b30] | 508 | |
---|
[c123a084] | 509 | /* exercise pthread_getschedparam */ |
---|
| 510 | |
---|
| 511 | empty_line(); |
---|
| 512 | |
---|
[c9c05a0] | 513 | puts( "Init - pthread_getschedparam - EINVAL (NULL policy)" ); |
---|
[c123a084] | 514 | status = pthread_getschedparam( pthread_self(), NULL, &schedparam ); |
---|
[01618ccc] | 515 | fatal_directive_check_status_only( status, EINVAL, "NULL policy" ); |
---|
[1b4f2b30] | 516 | |
---|
[c9c05a0] | 517 | puts( "Init - pthread_getschedparam - EINVAL (NULL schedparam)" ); |
---|
[c123a084] | 518 | status = pthread_getschedparam( pthread_self(), &schedpolicy, NULL ); |
---|
[01618ccc] | 519 | fatal_directive_check_status_only( status, EINVAL, "NULL schedparam" ); |
---|
[1b4f2b30] | 520 | |
---|
[c9c05a0] | 521 | puts( "Init - pthread_getschedparam - ESRCH (bad thread)" ); |
---|
[2e7e636f] | 522 | status = pthread_getschedparam( (pthread_t) -1, &schedpolicy, &schedparam ); |
---|
[01618ccc] | 523 | fatal_directive_check_status_only( status, ESRCH, "bad thread" ); |
---|
[1b4f2b30] | 524 | |
---|
[c9c05a0] | 525 | puts( "Init - pthread_getschedparam - SUCCESSFUL" ); |
---|
[c123a084] | 526 | status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); |
---|
[01618ccc] | 527 | posix_service_failed( status, "pthread_getschedparam"); |
---|
[1b4f2b30] | 528 | |
---|
[c9c05a0] | 529 | printf( "Init - policy = %d\n", schedpolicy ); |
---|
[c123a084] | 530 | |
---|
[c9c05a0] | 531 | print_schedparam( "Init - ", &schedparam ); |
---|
[c123a084] | 532 | |
---|
| 533 | /* exercise pthread_setschedparam */ |
---|
| 534 | |
---|
| 535 | empty_line(); |
---|
| 536 | |
---|
[c9c05a0] | 537 | puts( "Init - pthread_setschedparam - EINVAL (NULL schedparam)" ); |
---|
[c123a084] | 538 | status = pthread_setschedparam( pthread_self(), SCHED_OTHER, NULL ); |
---|
[01618ccc] | 539 | fatal_directive_check_status_only( status, EINVAL, "NULL schedparam" ); |
---|
[c123a084] | 540 | |
---|
| 541 | schedparam.sched_priority = -1; |
---|
| 542 | |
---|
[c9c05a0] | 543 | puts( "Init - pthread_setschedparam - EINVAL (invalid priority)" ); |
---|
[c123a084] | 544 | status = pthread_setschedparam( pthread_self(), SCHED_OTHER, NULL ); |
---|
[01618ccc] | 545 | fatal_directive_check_status_only( status, EINVAL, "invalid priority" ); |
---|
[c123a084] | 546 | |
---|
[69ca55c0] | 547 | /* reset sched_param */ |
---|
| 548 | status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); |
---|
| 549 | posix_service_failed( status, "pthread_getschedparam"); |
---|
[c123a084] | 550 | |
---|
[c9c05a0] | 551 | puts( "Init - pthread_setschedparam - EINVAL (invalid policy)" ); |
---|
[c123a084] | 552 | status = pthread_setschedparam( pthread_self(), -1, &schedparam ); |
---|
[01618ccc] | 553 | fatal_directive_check_status_only( status, EINVAL, "invalid policy" ); |
---|
[c123a084] | 554 | |
---|
[c9c05a0] | 555 | puts( "Init - pthread_setschedparam - ESRCH (invalid thread)" ); |
---|
[2e7e636f] | 556 | status = pthread_setschedparam( (pthread_t) -1, SCHED_OTHER, &schedparam ); |
---|
[01618ccc] | 557 | fatal_directive_check_status_only( status, ESRCH, "invalid thread" ); |
---|
[c123a084] | 558 | |
---|
[1b4f2b30] | 559 | /* now get sporadic server errors */ |
---|
[c123a084] | 560 | |
---|
[66c9ad8] | 561 | schedparam.sched_ss_repl_period.tv_sec = 0; |
---|
| 562 | schedparam.sched_ss_repl_period.tv_nsec = 0; |
---|
| 563 | schedparam.sched_ss_init_budget.tv_sec = 1; |
---|
| 564 | schedparam.sched_ss_init_budget.tv_nsec = 1; |
---|
[c9c05a0] | 565 | |
---|
| 566 | puts( "Init - pthread_setschedparam - EINVAL (replenish == 0)" ); |
---|
| 567 | status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); |
---|
| 568 | fatal_directive_check_status_only( status, EINVAL, "replenish == 0" ); |
---|
| 569 | |
---|
[66c9ad8] | 570 | schedparam.sched_ss_repl_period.tv_sec = 1; |
---|
| 571 | schedparam.sched_ss_repl_period.tv_nsec = 1; |
---|
| 572 | schedparam.sched_ss_init_budget.tv_sec = 0; |
---|
| 573 | schedparam.sched_ss_init_budget.tv_nsec = 0; |
---|
[c9c05a0] | 574 | |
---|
| 575 | puts( "Init - pthread_setschedparam - EINVAL (budget == 0)" ); |
---|
| 576 | status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); |
---|
| 577 | fatal_directive_check_status_only( status, EINVAL, "budget == 0" ); |
---|
| 578 | |
---|
[66c9ad8] | 579 | schedparam.sched_ss_repl_period.tv_sec = 1; |
---|
| 580 | schedparam.sched_ss_repl_period.tv_nsec = 0; |
---|
| 581 | schedparam.sched_ss_init_budget.tv_sec = 1; |
---|
| 582 | schedparam.sched_ss_init_budget.tv_nsec = 1; |
---|
[c123a084] | 583 | |
---|
[c9c05a0] | 584 | puts( "Init - pthread_setschedparam - EINVAL (replenish < budget)" ); |
---|
[c123a084] | 585 | status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); |
---|
[01618ccc] | 586 | fatal_directive_check_status_only( status, EINVAL, "replenish < budget" ); |
---|
[c123a084] | 587 | |
---|
[66c9ad8] | 588 | schedparam.sched_ss_repl_period.tv_sec = 2; |
---|
| 589 | schedparam.sched_ss_repl_period.tv_nsec = 0; |
---|
| 590 | schedparam.sched_ss_init_budget.tv_sec = 1; |
---|
| 591 | schedparam.sched_ss_init_budget.tv_nsec = 0; |
---|
| 592 | schedparam.sched_ss_low_priority = -1; |
---|
[c123a084] | 593 | |
---|
[c9c05a0] | 594 | puts( "Init - pthread_setschedparam - EINVAL (invalid priority)" ); |
---|
[c123a084] | 595 | status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); |
---|
[01618ccc] | 596 | fatal_directive_check_status_only( status, EINVAL, "invalid priority" ); |
---|
[c123a084] | 597 | |
---|
[712726d] | 598 | /* |
---|
| 599 | * Create a sporadic thread that doesn't need it's priority |
---|
| 600 | * boosted |
---|
| 601 | */ |
---|
| 602 | empty_line(); |
---|
| 603 | |
---|
| 604 | puts( "Init - pthread_attr_init - SUCCESSFUL" ); |
---|
| 605 | status = pthread_attr_init( &attr ); |
---|
| 606 | posix_service_failed( status, "pthread_attr_init" ); |
---|
| 607 | |
---|
| 608 | puts( "Init - pthread_attr_setinheritsched - EXPLICIT - SUCCESSFUL" ); |
---|
| 609 | status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); |
---|
[2cc30e90] | 610 | rtems_test_assert( !status ); |
---|
[712726d] | 611 | |
---|
[66c9ad8] | 612 | schedparam.sched_ss_repl_period.tv_sec = 3; |
---|
| 613 | schedparam.sched_ss_repl_period.tv_nsec = 3; |
---|
| 614 | schedparam.sched_ss_init_budget.tv_sec = 1; |
---|
| 615 | schedparam.sched_ss_init_budget.tv_nsec = 1; |
---|
[712726d] | 616 | schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO ); |
---|
[66c9ad8] | 617 | schedparam.sched_ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6; |
---|
[712726d] | 618 | |
---|
| 619 | puts( "Init - pthread_attr_setschedpolicy - SUCCESSFUL" ); |
---|
| 620 | status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC ); |
---|
| 621 | posix_service_failed( status, "pthread_attr_setschedparam"); |
---|
| 622 | puts( "Init - pthread_attr_setschedparam - SUCCESSFUL" ); |
---|
| 623 | status = pthread_attr_setschedparam( &attr, &schedparam ); |
---|
| 624 | posix_service_failed( status, "pthread_attr_setschedparam"); |
---|
| 625 | |
---|
| 626 | status = pthread_create( &Task2_id, &attr, Task_2, NULL ); |
---|
[33c46f1] | 627 | rtems_test_assert( !status ); |
---|
[712726d] | 628 | |
---|
| 629 | status = pthread_join( Task2_id, NULL ); |
---|
| 630 | posix_service_failed( status, " pthread_join"); |
---|
| 631 | |
---|
[698c2e50] | 632 | TEST_END(); |
---|
[d802489] | 633 | rtems_test_exit( 0 ); |
---|
[870f2976] | 634 | |
---|
| 635 | return NULL; /* just so the compiler thinks we returned something */ |
---|
| 636 | } |
---|