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 rtems_task Priority_task(
0036 rtems_task_argument its_index_arg
0037 )
0038 {
0039 rtems_interval timeout;
0040 rtems_task_priority its_priority;
0041 rtems_task_priority current_priority;
0042 rtems_status_code status;
0043 int its_index;
0044 uint32_t index;
0045
0046 its_index = (int) its_index_arg;
0047 its_priority = Task_priority[ its_index ];
0048
0049 if ( its_priority < 3 )
0050 timeout = 5 * rtems_clock_get_ticks_per_second();
0051 else
0052 timeout = RTEMS_NO_TIMEOUT;
0053
0054 put_name( Priority_task_name[ its_index ], FALSE );
0055 puts( " - rtems_semaphore_obtain - wait forever on SM2" );
0056
0057 status = rtems_semaphore_obtain(
0058 Semaphore_id[ 2 ],
0059 RTEMS_DEFAULT_OPTIONS,
0060 timeout
0061 );
0062 directive_failed( status, "rtems_semaphore_obtain of SM2" );
0063
0064 if ( its_priority < PRIORITY_INHERIT_BASE_PRIORITY ) {
0065 printf(
0066 "PRI%d - WHY AM I HERE? (pri=%" PRIdrtems_task_priority ")",
0067 its_index,
0068 its_priority
0069 );
0070 rtems_test_exit( 0 );
0071 }
0072
0073
0074 {
0075 rtems_task_priority priority;
0076 rtems_task_priority old_priority;
0077
0078 puts( "Set priority of self while holding resource" );
0079 status =
0080 rtems_task_set_priority( RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority );
0081 directive_failed( status, "rtems_task_set_priority get current" );
0082 status = rtems_task_set_priority( RTEMS_SELF, priority, &old_priority );
0083 directive_failed( status, "rtems_task_set_priority with resource" );
0084 if ( priority != old_priority ) {
0085 printf(
0086 "priority != old_priority (%" PRIdrtems_task_priority
0087 " != %" PRIdrtems_task_priority ")\n",
0088 priority,
0089 old_priority
0090 );
0091 rtems_test_exit(0);
0092 }
0093 }
0094
0095 if ( its_index == 5 )
0096 puts( "PRI5 - rtems_task_suspend - until all priority tasks blocked" );
0097 status = rtems_task_suspend( RTEMS_SELF );
0098 directive_failed( status, "rtems_task_suspend" );
0099
0100 puts( "PRI5 - rtems_task_delete - all tasks waiting on SM2" );
0101 for ( index = 1 ; index < 5 ; index++ ) {
0102 status = rtems_task_delete( Priority_task_id[ index ] );
0103 directive_failed( status, "rtems_task_delete loop" );
0104 }
0105
0106 puts( "PRI5 - rtems_semaphore_obtain - nested" );
0107 status = rtems_semaphore_obtain(
0108 Semaphore_id[ 2 ],
0109 RTEMS_DEFAULT_OPTIONS,
0110 timeout
0111 );
0112 directive_failed( status, "rtems_semaphore_obtain nested" );
0113
0114 puts( "PRI5 - rtems_semaphore_release - nested" );
0115 status = rtems_semaphore_release( Semaphore_id[ 2 ] );
0116 directive_failed( status, "rtems_semaphore_release nested " );
0117
0118 puts( "PRI5 - rtems_semaphore_release - restore priority" );
0119 status = rtems_semaphore_release( Semaphore_id[ 2 ] );
0120 directive_failed( status, "rtems_semaphore_release" );
0121
0122 status = rtems_task_set_priority(
0123 RTEMS_SELF,
0124 RTEMS_CURRENT_PRIORITY,
0125 ¤t_priority
0126 );
0127 directive_failed( status, "PRI5 rtems_task_set_priority CURRENT" );
0128 printf(
0129 "PRI5 - priority of PRI5 is %" PRIdrtems_task_priority "\n",
0130 current_priority
0131 );
0132
0133 (void) rtems_task_suspend( RTEMS_SELF );
0134 }