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 | #include <tmacros.h> |
---|
13 | |
---|
14 | #define ALLOC_SIZE 400 |
---|
15 | uint8_t Region_Memory[512] CPU_STRUCTURE_ALIGNMENT; |
---|
16 | rtems_id Region; |
---|
17 | |
---|
18 | rtems_task Blocking_task( |
---|
19 | rtems_task_argument ignored |
---|
20 | ) |
---|
21 | { |
---|
22 | rtems_status_code status; |
---|
23 | void *address_1; |
---|
24 | |
---|
25 | puts( "Blocking_task - wait for memory" ); |
---|
26 | status = rtems_region_get_segment( |
---|
27 | Region, |
---|
28 | ALLOC_SIZE, |
---|
29 | RTEMS_DEFAULT_OPTIONS, |
---|
30 | RTEMS_NO_TIMEOUT, |
---|
31 | &address_1 |
---|
32 | ); |
---|
33 | directive_failed( status, "rtems_region_get_segment" ); |
---|
34 | |
---|
35 | puts( "Blocking_task - Got memory segment after freed" ); |
---|
36 | |
---|
37 | puts( "Blocking_task - delete self" ); |
---|
38 | status = rtems_task_delete(RTEMS_SELF); |
---|
39 | } |
---|
40 | |
---|
41 | rtems_task Init( |
---|
42 | rtems_task_argument ignored |
---|
43 | ) |
---|
44 | { |
---|
45 | rtems_status_code status; |
---|
46 | rtems_id task_id; |
---|
47 | void *address_1; |
---|
48 | rtems_task_priority priority; |
---|
49 | |
---|
50 | puts( "\n\n*** TEST 59 ***" ); |
---|
51 | |
---|
52 | priority = RTEMS_MAXIMUM_PRIORITY / 4; |
---|
53 | priority = (priority * 3) + (priority / 2); |
---|
54 | printf( "Init - blocking task priority will be %d\n", priority ); |
---|
55 | |
---|
56 | puts( "Init - rtems_task_create - delay task - OK" ); |
---|
57 | status = rtems_task_create( |
---|
58 | rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
59 | priority, |
---|
60 | RTEMS_MINIMUM_STACK_SIZE, |
---|
61 | RTEMS_DEFAULT_OPTIONS, |
---|
62 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
63 | &task_id |
---|
64 | ); |
---|
65 | directive_failed( status, "rtems_task_create" ); |
---|
66 | |
---|
67 | puts( "Init - rtems_task_start - delay task - OK" ); |
---|
68 | status = rtems_task_start( task_id, Blocking_task, 0 ); |
---|
69 | directive_failed( status, "rtems_task_start" ); |
---|
70 | |
---|
71 | puts( "Init - rtems_region_create - OK" ); |
---|
72 | status = rtems_region_create( |
---|
73 | rtems_build_name('R', 'N', '0', '1'), |
---|
74 | Region_Memory, |
---|
75 | sizeof( Region_Memory ), |
---|
76 | 64, |
---|
77 | RTEMS_PRIORITY, |
---|
78 | &Region |
---|
79 | ); |
---|
80 | directive_failed( status, "rtems_region_create of RN1" ); |
---|
81 | |
---|
82 | puts( "Init - rtems_region_get_segment - get segment to consume memory" ); |
---|
83 | rtems_region_get_segment( |
---|
84 | Region, |
---|
85 | ALLOC_SIZE, |
---|
86 | RTEMS_PRIORITY, |
---|
87 | RTEMS_NO_TIMEOUT, |
---|
88 | &address_1 |
---|
89 | ); |
---|
90 | directive_failed( status, "rtems_region_get_segment" ); |
---|
91 | |
---|
92 | puts( "Init - rtems_task_wake_after - let other task block - OK" ); |
---|
93 | status = rtems_task_wake_after( RTEMS_MILLISECONDS_TO_TICKS(1000) ); |
---|
94 | directive_failed( status, "rtems_task_wake_after" ); |
---|
95 | |
---|
96 | puts( "Init - rtems_region_get_segment - return segment" ); |
---|
97 | status = rtems_region_return_segment( Region, address_1 ); |
---|
98 | directive_failed( status, "rtems_region_return_segment" ); |
---|
99 | |
---|
100 | puts( "Init - rtems_task_wake_after - let other task run again - OK" ); |
---|
101 | status = rtems_task_wake_after( RTEMS_MILLISECONDS_TO_TICKS(1000) ); |
---|
102 | directive_failed( status, "rtems_task_wake_after" ); |
---|
103 | |
---|
104 | puts( "*** END OF TEST 59 ***" ); |
---|
105 | rtems_test_exit(0); |
---|
106 | } |
---|
107 | |
---|
108 | /* configuration information */ |
---|
109 | |
---|
110 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
111 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
112 | |
---|
113 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
114 | #define CONFIGURE_MAXIMUM_REGIONS 1 |
---|
115 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
116 | |
---|
117 | #define CONFIGURE_INIT |
---|
118 | #include <rtems/confdefs.h> |
---|
119 | |
---|
120 | /* global variables */ |
---|