diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-21 20:05:46 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-21 20:05:46 +0000 |
commit | e247b1af43f651b822fc524fb98d050b47dd7e8a (patch) | |
tree | 394a67bd7aae9e714ca18eb699fd52ef8822ced6 /testsuites/libtests/malloc02/init.c | |
parent | 2010-06-21 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-e247b1af43f651b822fc524fb98d050b47dd7e8a.tar.bz2 |
2010-06-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add test for deferring free() from ISR and
for deferred free() processing.
* malloc02/.cvsignore, malloc02/Makefile.am, malloc02/init.c,
malloc02/malloc02.doc, malloc02/malloc02.scn: New files.
Diffstat (limited to 'testsuites/libtests/malloc02/init.c')
-rw-r--r-- | testsuites/libtests/malloc02/init.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/testsuites/libtests/malloc02/init.c b/testsuites/libtests/malloc02/init.c new file mode 100644 index 0000000000..939fdcd748 --- /dev/null +++ b/testsuites/libtests/malloc02/init.c @@ -0,0 +1,95 @@ +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include <tmacros.h> + +volatile bool operation_performed_from_tsr; + +void *Pointer1; + +rtems_timer_service_routine test_operation_from_isr( + rtems_id timer, + void *arg +) +{ + /* free memory from ISR so it is deferred */ + free( Pointer1 ); + + operation_performed_from_tsr = true; +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id timer; + void *pointer2; + + puts( "\n\n*** TEST MALLOC 02 ***" ); + + puts( "malloc memory to free from ISR" ); + Pointer1 = malloc( 20 ); + + /* + * Timer used in multiple ways + */ + status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer ); + directive_failed( status, "rtems_timer_create" ); + + operation_performed_from_tsr = false; + + /* + * Test Operation from ISR + */ + status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL ); + directive_failed( status, "timer_fire_after failed" ); + + /* XXX pick a delay method */ +#if 0 + status = rtems_task_wake_after( 20 ); +#else + { + rtems_interval start; + rtems_interval now; + start = rtems_clock_get_ticks_since_boot(); + do { + now = rtems_clock_get_ticks_since_boot(); + } while ( (now-start) < 100 ); + } +#endif + if ( !operation_performed_from_tsr ) { + puts( "Operation from ISR did not get processed\n" ); + rtems_test_exit( 0 ); + } + + puts( "Free from ISR successfully processed" ); + puts( "Now malloc'ing more memory to process the free" ); + pointer2 = malloc(20); + + puts( "*** END OF TEST MALLOC 02 ***" ); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_TIMERS 1 + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> +/* end of file */ + |