File indexing completed on 2025-05-11 08:24:44
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
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include "system.h"
0034
0035 void Priority_test_driver(
0036 rtems_task_priority priority_base
0037 )
0038 {
0039 rtems_task_priority previous_priority;
0040 uint32_t index;
0041 rtems_status_code status;
0042
0043 for ( index = 1 ; index <= 5 ; index++ ) {
0044 switch ( index ) {
0045 case 1:
0046 case 2:
0047 case 3:
0048 Task_priority[ index ] = priority_base + index;
0049 break;
0050 default:
0051 Task_priority[ index ] = priority_base + 3;
0052 break;
0053 }
0054
0055 status = rtems_task_create(
0056 Priority_task_name[ index ],
0057 Task_priority[ index ],
0058 RTEMS_MINIMUM_STACK_SIZE * 2,
0059 RTEMS_DEFAULT_MODES,
0060 RTEMS_DEFAULT_ATTRIBUTES,
0061 &Priority_task_id[ index ]
0062 );
0063 directive_failed( status, "rtems_task_create loop" );
0064
0065 }
0066
0067 if ( priority_base == 0 ) {
0068 for ( index = 1 ; index <= 5 ; index++ ) {
0069 status = rtems_task_start(
0070 Priority_task_id[ index ],
0071 Priority_task,
0072 index
0073 );
0074 directive_failed( status, "rtems_task_start loop" );
0075 }
0076 } else {
0077 for ( index = 5 ; index >= 1 ; index-- ) {
0078 status = rtems_task_start(
0079 Priority_task_id[ index ],
0080 Priority_task,
0081 index
0082 );
0083 directive_failed( status, "rtems_task_start loop" );
0084
0085 status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0086 directive_failed( status, "rtems_task_wake_after loop" );
0087
0088 if ( priority_base == PRIORITY_INHERIT_BASE_PRIORITY ) {
0089 if ( index == 4 ) {
0090 status = rtems_task_set_priority(
0091 Priority_task_id[ 5 ],
0092 priority_base + 4,
0093 &previous_priority
0094 );
0095 printf(
0096 "PDRV - change priority of PRI5 from %" PRIdrtems_task_priority
0097 " to %" PRIdrtems_task_priority "\n",
0098 previous_priority,
0099 priority_base + 4
0100 );
0101 directive_failed( status, "PDRV rtems_task_set_priority" );
0102 }
0103 status = rtems_task_set_priority(
0104 Priority_task_id[ 5 ],
0105 RTEMS_CURRENT_PRIORITY,
0106 &previous_priority
0107 );
0108 directive_failed( status, "PDRV rtems_task_set_priority CURRENT" );
0109 printf(
0110 "PDRV - priority of PRI5 is %" PRIdrtems_task_priority "\n",
0111 previous_priority
0112 );
0113 }
0114 }
0115 }
0116
0117 status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0118 directive_failed( status, "rtems_task_wake_after after loop" );
0119
0120 if ( priority_base == 0 ) {
0121 for ( index = 1 ; index <= 5 ; index++ ) {
0122 status = rtems_semaphore_release( Semaphore_id[ 2 ] );
0123 directive_failed( status, "rtems_semaphore_release loop" );
0124 }
0125 }
0126
0127 if ( priority_base == PRIORITY_INHERIT_BASE_PRIORITY ) {
0128 puts( "PDRV - rtems_task_resume - PRI5" );
0129 status = rtems_task_resume( Priority_task_id[ 5 ] );
0130 directive_failed( status, "rtems_task_resume" );
0131
0132 status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0133 directive_failed( status, "rtems_task_wake_after so PRI5 can run" );
0134
0135 status = rtems_task_delete( Priority_task_id[ 5 ] );
0136 directive_failed( status, "rtems_task_delete of PRI5" );
0137 } else {
0138 for ( index = 1 ; index <= 5 ; index++ ) {
0139 status = rtems_task_delete( Priority_task_id[ index ] );
0140 directive_failed( status, "rtems_task_delete loop" );
0141 }
0142 }
0143 }