Changeset 0e4232b in rtems
- Timestamp:
- Jan 18, 2008, 4:33:35 PM (12 years ago)
- Branches:
- 4.10, 4.11, 4.9, master
- Children:
- 0c76166
- Parents:
- c3925db
- Location:
- testsuites/psxtests
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
testsuites/psxtests/ChangeLog
rc3925db r0e4232b 1 2008-01-18 Jennifer Averett <jennifer.averett@OARcorp.com> 2 3 * psx01/init.c, psxmsgq01/init.c, psxtimer01/psxtimer.c, 4 psxtimer01/psxtimer01.scn, psxtimer02/psxtimer.c: 5 1 6 2007-12-20 Joel Sherrill <joel.sherrill@oarcorp.com> 2 7 -
testsuites/psxtests/psx01/init.c
rc3925db r0e4232b 1 1 /* 2 * COPYRIGHT (c) 1989- 1999.2 * COPYRIGHT (c) 1989-2008. 3 3 * On-Line Applications Research Corporation (OAR). 4 4 * … … 53 53 /* error cases in clock_gettime and clock_settime */ 54 54 55 puts( "Init: clock_gettime - EINVAL (NULL timespec)" ); 56 status = clock_gettime( CLOCK_REALTIME, NULL ); 57 assert( status == -1 ); 58 assert( errno == EINVAL ); 59 55 60 puts( "Init: clock_gettime - EINVAL (invalid clockid)" ); 56 status = clock_ settime( -1, &tv );61 status = clock_gettime( -1, &tv ); 57 62 assert( status == -1 ); 58 63 assert( errno == EINVAL ); … … 103 108 remaining = sleep( 3 ); 104 109 assert( !remaining ); 105 110 106 111 /* print new times to make sure it has changed and we can get the realtime */ 112 status = clock_gettime( CLOCK_PROCESS_CPUTIME, &tv ); 113 assert( !status ); 114 printf("Time since boot: (%d, %d)\n", tv.tv_sec,tv.tv_nsec ); 107 115 108 116 status = clock_gettime( CLOCK_REALTIME, &tv ); -
testsuites/psxtests/psxmsgq01/init.c
rc3925db r0e4232b 1 1 /* 2 * COPYRIGHT (c) 1989- 1999.2 * COPYRIGHT (c) 1989-2008. 3 3 * On-Line Applications Research Corporation (OAR). 4 4 * … … 44 44 } Test_queue_type; 45 45 46 Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES ] =46 Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES + 1 ] = 47 47 { 48 48 { 0, 0, "Qread", ( O_CREAT | O_RDONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 }, … … 52 52 { 0, 4, "Qdefault", ( O_CREAT | O_RDWR ) , 10, 16, 0 }, 53 53 { 0, 5, "mq6", ( O_CREAT | O_WRONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 }, 54 { 0, 6, "Qblock", ( O_RDWR ) , MAXMSG, MSGSIZE, 0 }, 54 55 }; 55 56 … … 131 132 puts( "Init: Open Test Queues" ); 132 133 133 for( que = 0; que < NUMBER_OF_TEST_QUEUES ; que++ ) {134 for( que = 0; que < NUMBER_OF_TEST_QUEUES+1; que++ ) { 134 135 135 136 tq = &Test_q[ que ]; … … 142 143 } 143 144 145 status = mq_close( Test_q[NUMBER_OF_TEST_QUEUES].mq ); 146 fatal_posix_service_status( status, 0, "mq_close duplicate message queue"); 144 147 status = mq_close( Test_q[CLOSED].mq ); 145 148 fatal_posix_service_status( status, 0, "mq_close message queue"); … … 950 953 * XXX setup notification 951 954 */ 952 953 955 printf( "_____mq_notify - notify when %s gets a message\n",RW_NAME); 954 956 status = mq_notify( Test_q[RW_QUEUE].mq, &event ); -
testsuites/psxtests/psxtimer01/psxtimer.c
rc3925db r0e4232b 28 28 #include <time.h> /* time facilities */ 29 29 #include <stdio.h> /* console facilities */ 30 30 #include <rtems/score/timespec.h> 31 31 32 32 … … 35 35 struct periodic_params { 36 36 struct timespec period; 37 int count; /* Number of iterations to run */ 37 38 int signo; /* signal number */ 38 39 int id; /* task identification */ … … 47 48 pthread_cond_t sync; 48 49 int updated; 49 int x;50 50 }; 51 51 52 52 struct shared_data data; 53 53 54 void StopTimer( 55 timer_t timer_id, 56 struct itimerspec *timerdata 57 ) 58 { 59 timerdata->it_value.tv_sec = 0; 60 timerdata->it_value.tv_nsec = 0; 61 if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,timerdata,NULL) == -1) { 62 perror ("Error in timer setting\n"); 63 pthread_exit ((void *) -1); 64 } 65 } 66 54 67 /* task A */ 55 56 68 void * task_a (void *arg) 57 69 { … … 59 71 int my_sig, received_sig; 60 72 struct itimerspec timerdata; 73 struct itimerspec timergetdata; 61 74 timer_t timer_id; 62 75 time_t clock; 63 76 struct sigevent event; 64 77 sigset_t set; 65 66 my_period = ((struct periodic_params*) arg)->period; 67 my_sig = ((struct periodic_params*) arg)->signo; 78 struct periodic_params *params; 79 80 params = arg; 81 my_period = params->period; 82 my_sig = params->signo; 68 83 69 84 /* timer create */ … … 83 98 timerdata.it_interval = my_period; 84 99 timerdata.it_value = my_period; 85 if (timer_settime(timer_id, 0, &timerdata, NULL) == -1) {100 if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,&timerdata,&timergetdata) == -1) { 86 101 perror ("Error in timer setting\n"); 87 102 pthread_exit ((void *) -1); 88 103 } 104 printf( 105 "task A: timer_settime - value=%d:%d interval=%d:%d\n", 106 timergetdata.it_value.tv_sec, timergetdata.it_value.tv_nsec, 107 timergetdata.it_interval.tv_sec, timergetdata.it_interval.tv_nsec 108 ); 109 89 110 90 111 /* periodic activity */ … … 93 114 perror ("Error in sigwait\n"); 94 115 } 116 if (timer_gettime(timer_id, &timerdata) == -1) { 117 perror ("Error in timer_gettime\n"); 118 pthread_exit ((void *) -1); 119 } 120 if (! _Timespec_Equal_to( &timerdata.it_value, &my_period )){ 121 perror ("Error in Task A timer_gettime\n"); 122 } 95 123 clock = time(NULL); 96 printf("Executing task A %s", ctime(&clock)); 124 printf("Executing task A with count = %2i %s", params->count, ctime(&clock)); 125 params->count--; 126 if (params->count == 0) 127 StopTimer(timer_id, &timerdata); 97 128 } 98 129 return NULL; … … 110 141 struct sigevent event; 111 142 sigset_t set; 112 113 int x; /* value to be copied to the shared datum */ 114 115 my_period = ((struct periodic_params*) arg)->period; 116 my_sig = ((struct periodic_params*) arg)->signo; 117 118 x = 1; 143 struct periodic_params *params; 144 145 params = arg; 146 my_period = params->period; 147 my_sig = params->signo; 148 119 149 120 150 /* timer create */ … … 133 163 /* set the timer in periodic mode */ 134 164 timerdata.it_interval = my_period; 135 timerdata.it_value = my_period; 136 if (timer_settime(timer_id, 0, &timerdata, NULL) == -1) { 165 timerdata.it_value = _TOD_Now; 166 _Timespec_Add_to( &timerdata.it_value, &my_period); 167 if (timer_settime(timer_id,TIMER_ABSTIME,&timerdata,NULL) == -1) { 137 168 perror ("Error in timer setting\n"); 138 169 pthread_exit ((void *) -1); 139 } 170 } 140 171 141 172 /* periodic activity */ … … 145 176 pthread_exit ((void *) -1); 146 177 } 178 179 if (timer_gettime(timer_id, &timerdata) == -1) { 180 perror ("Error in timer_gettime\n"); 181 pthread_exit ((void *) -1); 182 } 183 if (! _Timespec_Equal_to( &timerdata.it_value, &my_period) ){ 184 perror ("Error in Task B timer_gettime\n"); 185 } 186 147 187 pthread_mutex_lock (&data.mutex); 148 188 clock = time(NULL); 149 printf("Executing task B with x = %i %s", x, ctime(&clock)); 150 data.x = x; 189 printf("Executing task B with count = %2i %s\n", 190 params->count, ctime(&clock) 191 ); 151 192 data.updated = TRUE; 152 193 pthread_cond_signal (&data.sync); 153 194 pthread_mutex_unlock (&data.mutex); 154 x++; 195 params->count--; 196 if (params->count == 0) 197 StopTimer(timer_id, &timerdata); 155 198 } 156 199 return NULL; … … 161 204 void * task_c (void *arg) 162 205 { 206 int count; 163 207 struct timespec my_period; 164 208 int my_sig, received_sig; 165 209 struct itimerspec timerdata; 210 struct itimerspec timergetdata; 166 211 timer_t timer_id; 167 212 time_t clock; 168 213 struct sigevent event; 169 214 sigset_t set; 170 171 int x; /* value to be copied to the shared datum */ 172 173 my_period = ((struct periodic_params*) arg)->period; 174 my_sig = ((struct periodic_params*) arg)->signo; 175 176 x = 0; 215 struct periodic_params *params; 216 217 params = arg; 218 my_period = params->period; 219 my_sig = params->signo; 177 220 178 221 /* timer create */ … … 192 235 timerdata.it_interval = my_period; 193 236 timerdata.it_value = my_period; 194 if (timer_settime(timer_id, 0, &timerdata,NULL) == -1) {237 if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,&timerdata,NULL) == -1) { 195 238 perror ("Error in timer setting\n"); 196 239 pthread_exit ((void *) -1); … … 198 241 199 242 /* periodic activity */ 200 while(1) {243 for (count=0 ; ; count++) { 201 244 if (sigwait(&set,&received_sig) == -1) { 202 245 perror ("Error in sigwait\n"); 203 246 pthread_exit ((void *) -1); 204 247 } 248 if (timer_gettime(timer_id, &timerdata) == -1) { 249 perror ("Error in timer_gettime\n"); 250 pthread_exit ((void *) -1); 251 } 252 if (! _Timespec_Equal_to( &timerdata.it_value, &my_period) ){ 253 perror ("Error in Task C timer_gettime\n"); 254 } 205 255 pthread_mutex_lock (&data.mutex); 206 256 while (data.updated == FALSE) { 207 257 pthread_cond_wait (&data.sync,&data.mutex); 208 258 } 209 x = data.x;210 259 clock = time(NULL); 211 printf("Executing task C with x = %i %s", x, ctime(&clock)); 260 printf("Executing task C with count = %2i %s\n", 261 params->count, ctime(&clock) 262 ); 263 264 if ( count && (count % 5) == 0 ) { 265 int overruns = 0; 266 sleep(1); 267 overruns = timer_getoverrun( timer_id ); 268 printf( "task C: timer_getoverrun - overruns=%d\n", overruns ); 269 270 if (timer_gettime(timer_id, &timergetdata) == -1) { 271 perror ("Error in timer setting\n"); 272 pthread_exit ((void *) -1); 273 } 274 printf( 275 "task C: timer_gettime - %d:%d remaining from %d:%d\n", 276 timergetdata.it_value.tv_sec, timergetdata.it_value.tv_nsec, 277 timergetdata.it_interval.tv_sec, timergetdata.it_interval.tv_nsec 278 ); 279 } 280 212 281 pthread_mutex_unlock (&data.mutex); 282 params->count--; 283 if (params->count == 0) 284 StopTimer(timer_id, &timerdata); 213 285 } 214 286 return NULL; 215 287 } 216 217 288 218 289 /* main */ … … 235 306 236 307 data.updated = FALSE; 237 data.x = 0;238 308 239 309 /* mask signal */ … … 268 338 269 339 /* set explicit schedule for every task */ 270 if (pthread_attr_setinheritsched (&attr, 271 PTHREAD_EXPLICIT_SCHED) != 0) { 340 if (pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED) != 0) { 272 341 perror("Error in attribute inheritsched\n"); 273 342 } 274 343 275 344 /* set task independent (join will not use) */ 276 if (pthread_attr_setdetachstate (&attr, 277 PTHREAD_CREATE_DETACHED) != 0) { 345 if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0) { 278 346 perror ("Error in attribute detachstate\n"); 279 347 } … … 281 349 /* schedule policy POSIX_FIFO (priority preemtive and FIFO within the same 282 350 priority) */ 283 if (pthread_attr_setschedpolicy (&attr, 284 SCHED_FIFO) != 0) { 351 if (pthread_attr_setschedpolicy (&attr, SCHED_FIFO) != 0) { 285 352 perror ("Error in attribute setschedpolicy\n"); 286 353 } … … 297 364 params_a.period.tv_sec = 1; /* seconds */ 298 365 params_a.period.tv_nsec = 000000000; /* nanoseconds */ 366 params_a.count = 20; 299 367 params_a.signo = SIGALRM; 300 368 if (pthread_create (&ta, &attr, task_a, ¶ms_a) != 0 ) { … … 312 380 params_b.period.tv_sec = 2; /* seconds */ 313 381 params_b.period.tv_nsec = 000000000; /* nanoseconds */ 382 params_b.count = 10; 314 383 params_b.signo = SIGALRM; 315 384 if (pthread_create (&tb, &attr, task_b, ¶ms_b) != 0) { … … 327 396 params_c.period.tv_sec = 3; /* seconds */ 328 397 params_c.period.tv_nsec = 000000000; /* nanoseconds */ 398 params_c.count = 6; 329 399 params_c.signo = SIGALRM; 330 400 if (pthread_create (&tc, &attr, task_c, ¶ms_c) != 0) { … … 333 403 334 404 335 /* execute 2 0seconds and finish */336 sleep (2 0);405 /* execute 25 seconds and finish */ 406 sleep (25); 337 407 puts( "*** END OF POSIX Timers Test 01 ***" ); 338 408 rtems_test_exit (0); -
testsuites/psxtests/psxtimer01/psxtimer01.scn
rc3925db r0e4232b 1 1 *** POSIX Timers Test 01 *** 2 task A: timer_settime - value=0:0 interval=0:0 2 3 Executing task A Fri Jan 1 00:00:01 1988 3 4 Executing task B with x = 1 Fri Jan 1 00:00:02 1988 … … 33 34 Executing task C with x = 9 Fri Jan 1 00:00:18 1988 34 35 Executing task A Fri Jan 1 00:00:18 1988 36 task C: timer_getoverrun - overruns=0 37 task C: timer_gettime - 2:0 remaining from 3:0 35 38 Executing task A Fri Jan 1 00:00:19 1988 36 39 Executing task B with x = 10 Fri Jan 1 00:00:20 1988 -
testsuites/psxtests/psxtimer02/psxtimer.c
rc3925db r0e4232b 93 93 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #2" ); 94 94 95 itimer.it_value = _TOD_Now; 96 itimer.it_value.tv_sec = itimer.it_value.tv_sec - 1; 97 puts( "timer_settime - bad itimer value - previous time - EINVAL" ); 98 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL ); 99 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #3" ); 100 95 101 itimer.it_value.tv_nsec = 0; 96 102 puts( "timer_settime - bad clock value - EINVAL" );
Note: See TracChangeset
for help on using the changeset viewer.