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 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> |
---|
15 | |
---|
16 | rtems_task Init( |
---|
17 | rtems_task_argument ignored |
---|
18 | ) |
---|
19 | { |
---|
20 | rtems_id task_id; |
---|
21 | rtems_status_code sc; |
---|
22 | bool sb; |
---|
23 | Heap_Information_block start; |
---|
24 | Heap_Information_block info; |
---|
25 | size_t stack_size; |
---|
26 | |
---|
27 | puts( "\n\n*** TEST 18 ***" ); |
---|
28 | |
---|
29 | puts( "Init - rtems_workspace_get_information - OK" ); |
---|
30 | sb = rtems_workspace_get_information( &start ); |
---|
31 | rtems_test_assert( sb ); |
---|
32 | |
---|
33 | #if 0 |
---|
34 | printf( "Init - workspace free = %d\n", start.Free.largest ); |
---|
35 | printf( "Init - workspace free blocks = %d\n", start.Free.number ); |
---|
36 | #endif |
---|
37 | rtems_test_assert( start.Free.number == 1 ); |
---|
38 | stack_size = start.Free.largest; |
---|
39 | |
---|
40 | #if 0 |
---|
41 | printf( "Init - start with stack size of = %d\n", stack_size ); |
---|
42 | #endif |
---|
43 | |
---|
44 | puts( "Init - rtems_task_create - Unsatisfied on Extensions" ); |
---|
45 | while (1) { |
---|
46 | |
---|
47 | sc = rtems_task_create( |
---|
48 | rtems_build_name( 'T', 'E', 'S', 'T' ), |
---|
49 | 1, |
---|
50 | stack_size, |
---|
51 | RTEMS_DEFAULT_MODES, |
---|
52 | RTEMS_FLOATING_POINT, |
---|
53 | &task_id |
---|
54 | ); |
---|
55 | |
---|
56 | if ( sc == RTEMS_SUCCESSFUL ) |
---|
57 | break; |
---|
58 | |
---|
59 | fatal_directive_status( sc, RTEMS_UNSATISFIED, "rtems_task_create" ); |
---|
60 | |
---|
61 | /* |
---|
62 | * Verify heap is still in same shape if we couldn't allocate a task |
---|
63 | */ |
---|
64 | sb = rtems_workspace_get_information( &info ); |
---|
65 | rtems_test_assert( sb ); |
---|
66 | rtems_test_assert( info.Free.largest == start.Free.largest ); |
---|
67 | rtems_test_assert( info.Free.number == start.Free.number ); |
---|
68 | |
---|
69 | stack_size -= 8; |
---|
70 | if ( stack_size <= RTEMS_MINIMUM_STACK_SIZE ) |
---|
71 | break; |
---|
72 | } |
---|
73 | |
---|
74 | if ( sc != RTEMS_SUCCESSFUL ) |
---|
75 | rtems_test_exit(0); |
---|
76 | |
---|
77 | /* |
---|
78 | * Verify heap is still in same shape after we free the task |
---|
79 | */ |
---|
80 | puts( "Init - rtems_task_delete - OK" ); |
---|
81 | sc = rtems_task_delete( task_id ); |
---|
82 | directive_failed( sc, "rtems_task_delete" ); |
---|
83 | |
---|
84 | puts( "Init - verify workspace has same memory" ); |
---|
85 | sb = rtems_workspace_get_information( &info ); |
---|
86 | rtems_test_assert( sb ); |
---|
87 | rtems_test_assert( info.Free.largest == start.Free.largest ); |
---|
88 | rtems_test_assert( info.Free.number == start.Free.number ); |
---|
89 | |
---|
90 | puts( "*** END OF TEST 18 ***" ); |
---|
91 | rtems_test_exit(0); |
---|
92 | } |
---|
93 | |
---|
94 | /* configuration information */ |
---|
95 | |
---|
96 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
97 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
98 | |
---|
99 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
100 | #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 20 |
---|
101 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
102 | |
---|
103 | #define CONFIGURE_INIT |
---|
104 | #include <rtems/confdefs.h> |
---|
105 | |
---|
106 | /* global variables */ |
---|