File indexing completed on 2025-05-11 08:24:33
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 <tmacros.h>
0034
0035 const char rtems_test_name[] = "MALLOC 2";
0036
0037
0038 rtems_task Init(rtems_task_argument argument);
0039 rtems_timer_service_routine test_operation_from_isr(rtems_id timer, void *arg);
0040
0041 volatile bool operation_performed_from_tsr;
0042
0043 void *Pointer1;
0044
0045 rtems_timer_service_routine test_operation_from_isr(
0046 rtems_id timer,
0047 void *arg
0048 )
0049 {
0050
0051 free( Pointer1 );
0052
0053 operation_performed_from_tsr = true;
0054 }
0055
0056 rtems_task Init(
0057 rtems_task_argument argument
0058 )
0059 {
0060 rtems_status_code status;
0061 rtems_id timer;
0062 void *pointer2;
0063
0064 TEST_BEGIN();
0065
0066 puts( "malloc memory to free from ISR" );
0067 Pointer1 = malloc( 20 );
0068
0069
0070
0071
0072 status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer );
0073 directive_failed( status, "rtems_timer_create" );
0074
0075 operation_performed_from_tsr = false;
0076
0077
0078
0079
0080 status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL );
0081 directive_failed( status, "timer_fire_after failed" );
0082
0083
0084 status = rtems_task_wake_after( 20 );
0085 directive_failed( status, "timer_wake_after failed" );
0086
0087 if ( !operation_performed_from_tsr ) {
0088 puts( "Operation from ISR did not get processed\n" );
0089 rtems_test_exit( 0 );
0090 }
0091
0092 puts( "Free from ISR successfully processed" );
0093 puts( "Now malloc'ing more memory to process the free" );
0094 pointer2 = malloc(20);
0095 rtems_test_assert( pointer2 );
0096
0097 TEST_END();
0098 rtems_test_exit( 0 );
0099 }
0100
0101
0102
0103 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0104 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0105
0106 #define CONFIGURE_MALLOC_DIRTY
0107
0108 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0109
0110 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0111 #define CONFIGURE_MAXIMUM_TASKS 1
0112 #define CONFIGURE_MAXIMUM_TIMERS 1
0113
0114 #define CONFIGURE_INIT
0115 #include <rtems/confdefs.h>
0116
0117