source: rtems/testsuites/libtests/malloc02/init.c @ 7d3f9c6

4.115
Last change on this file since 7d3f9c6 was 7d3f9c6, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 07:37:03

Add HAVE_CONFIG_H.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <tmacros.h>
17
18volatile bool operation_performed_from_tsr;
19
20void *Pointer1;
21
22rtems_timer_service_routine test_operation_from_isr(
23  rtems_id  timer,
24  void     *arg
25)
26{
27  /* free memory from ISR so it is deferred */
28  free( Pointer1 );
29
30  operation_performed_from_tsr = true;
31}
32
33rtems_task Init(
34  rtems_task_argument argument
35)
36{
37  rtems_status_code     status;
38  rtems_id              timer;
39  void                 *pointer2;
40
41  puts( "\n\n*** TEST MALLOC 02 ***" );
42
43  puts( "malloc memory to free from ISR" );
44  Pointer1 = malloc( 20 );
45
46  /*
47   *  Timer used in multiple ways
48   */
49  status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer );
50  directive_failed( status, "rtems_timer_create" );
51
52  operation_performed_from_tsr = false;
53
54  /*
55   * Test Operation from ISR
56   */
57  status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL );
58  directive_failed( status, "timer_fire_after failed" );
59
60  /* delay to let timer fire */
61  status = rtems_task_wake_after( 20 );
62  directive_failed( status, "timer_wake_after failed" );
63
64  if ( !operation_performed_from_tsr ) {
65    puts( "Operation from ISR did not get processed\n" );
66    rtems_test_exit( 0 );
67  }
68
69  puts( "Free from ISR successfully processed" );
70  puts( "Now malloc'ing more memory to process the free" );
71  pointer2 = malloc(20);
72
73  puts( "*** END OF TEST MALLOC 02 ***" );
74  rtems_test_exit( 0 );
75}
76
77/* configuration information */
78
79#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
80#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
81
82#define CONFIGURE_MALLOC_DIRTY
83
84#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
85#define CONFIGURE_MAXIMUM_TASKS             1
86#define CONFIGURE_MAXIMUM_TIMERS            1
87
88#define CONFIGURE_INIT
89#include <rtems/confdefs.h>
90/* end of file */
91
Note: See TracBrowser for help on using the repository browser.