4 #include <rtems/error.h>
9 rtems_id shared_with_hi_sem;
10 rtems_id shared_with_lo_sem;
12 rtems_id release_hi_sem;
13 rtems_id release_mid_sem;
14 rtems_id release_lo_sem;
21 void block_delay(int delay)
33 rtems_task_argument argument
36 rtems_status_code status;
38 printf("THI created\n");
40 status=rtems_semaphore_obtain(release_hi_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
41 check_rtems_status(status, 0, "rtems_semaphore_obtain RHI from THI");
42 printf("THI released (RHI)\n");
44 status=rtems_semaphore_obtain(shared_with_hi_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
45 check_rtems_status(status, 0, "rtems_semaphore_obtain SHI from THI");
46 printf("THI obtained SHI\n");
50 printf("THI going to release SHI\n");
51 status=rtems_semaphore_release(shared_with_hi_sem);
52 check_rtems_status(status, 0, "rtems_semaphore_release SHI from THI");
53 printf("THI released SHI\n");
58 rtems_task_argument argument
61 rtems_status_code status;
63 printf("TMID created\n");
65 status=rtems_semaphore_obtain(release_mid_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
66 check_rtems_status(status, 0, "rtems_semaphore_obtain RMID from TMID");
67 printf("MID released (RMID)\n");
71 printf("MID going to sleep\n");
76 rtems_task_argument argument
79 rtems_status_code status;
81 printf("LO created\n");
83 status=rtems_semaphore_obtain(release_lo_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
84 check_rtems_status(status, 0, "rtems_semaphore_obtain RLO from TLO");
85 printf("TLO released (RLO)\n");
87 status=rtems_semaphore_obtain(shared_with_lo_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
88 check_rtems_status(status, 0, "rtems_semaphore_obtain SLO from TLO");
89 printf("TLO obtained SLO\n");
93 printf("TLO going to release SLO\n");
94 status=rtems_semaphore_release(shared_with_lo_sem);
95 check_rtems_status(status, 0, "rtems_semaphore_release SLO from TLO");
96 printf("TLO released SLO\n");
102 rtems_task_argument argument
105 rtems_status_code status;
106 rtems_task_priority prio;
108 status = rtems_task_wake_after( TICKS_PER_SECOND );
109 check_rtems_status( status, 0, "rtems_task_wake_after" );
111 printf("*** Starting up Task_1 ***\n");
114 status=rtems_semaphore_create(rtems_build_name('S','H','I',' '),
116 RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY|RTEMS_LOCAL,
118 &shared_with_hi_sem);
119 check_rtems_status( status, 0, "rtems_semaphore_create SHI" );
121 status=rtems_semaphore_create(rtems_build_name('S','L','O',' '),
123 RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY|RTEMS_LOCAL,
125 &shared_with_lo_sem);
126 check_rtems_status( status, 0, "rtems_semaphore_create SLO" );
128 status=rtems_semaphore_create(rtems_build_name('R','H','I',' '),
130 RTEMS_PRIORITY|RTEMS_SIMPLE_BINARY_SEMAPHORE|RTEMS_LOCAL,
133 check_rtems_status( status, 0, "rtems_semaphore_create RHI" );
135 status=rtems_semaphore_create(rtems_build_name('R','M','I','D'),
137 RTEMS_PRIORITY|RTEMS_SIMPLE_BINARY_SEMAPHORE|RTEMS_LOCAL,
140 check_rtems_status( status, 0, "rtems_semaphore_create RMID" );
142 status=rtems_semaphore_create(rtems_build_name('R','L','O',' '),
144 RTEMS_PRIORITY|RTEMS_SIMPLE_BINARY_SEMAPHORE|RTEMS_LOCAL,
147 check_rtems_status( status, 0, "rtems_semaphore_create RLO" );
149 status = rtems_task_create(rtems_build_name('T','H','I',' '),
151 RTEMS_MINIMUM_STACK_SIZE+0x1000,
152 RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
153 RTEMS_DEFAULT_ATTRIBUTES,
156 check_rtems_status(status, 0, "rtems_task_create THI");
158 status = rtems_task_create(rtems_build_name('T','M','I','D'),
160 RTEMS_MINIMUM_STACK_SIZE+0x1000,
161 RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
162 RTEMS_DEFAULT_ATTRIBUTES,
165 check_rtems_status(status, 0, "rtems_task_create MID");
167 status = rtems_task_create(rtems_build_name('T','L','O',' '),
169 RTEMS_MINIMUM_STACK_SIZE+0x1000,
170 RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
171 RTEMS_DEFAULT_ATTRIBUTES,
174 check_rtems_status(status, 0, "rtems_task_create LO");
176 status = rtems_task_start( hi_task_id, hi_task, 0 );
177 check_rtems_status(status, 0, "rtems_task_start THI\n");
179 status = rtems_task_start( mid_task_id, mid_task, 0 );
180 check_rtems_status(status, 0, "rtems_task_start MID\n");
182 status = rtems_task_start( lo_task_id, lo_task, 0 );
183 check_rtems_status(status, 0, "rtems_task_start LO\n");
189 status=rtems_semaphore_obtain(shared_with_lo_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
190 check_rtems_status(status, 0, "rtems_semaphore_obtain SLO");
191 printf("1 obtained SLO\n");
193 printf("1 going to release RLO\n");
194 status=rtems_semaphore_release(release_lo_sem);
195 check_rtems_status(status, 0, "rtems_semaphore_release RLO");
197 status=rtems_semaphore_obtain(shared_with_hi_sem,RTEMS_WAIT,RTEMS_NO_TIMEOUT);
198 check_rtems_status(status, 0, "rtems_semaphore_obtain SHI");
199 printf("1 obtained SHI\n");
201 printf("1 going to release RHI\n");
202 status=rtems_semaphore_release(release_hi_sem);
203 check_rtems_status(status, 0, "rtems_semaphore_release RHI");
205 status = rtems_task_wake_after( TICKS_PER_SECOND );
206 check_rtems_status( status, 0, "rtems_task_wake_after" );
208 status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
209 check_rtems_status( status, 0, "rtems_task_set_priority");
210 printf("1 priority is %d\n", (int)prio);
212 printf("1 going to release RMID\n");
213 status=rtems_semaphore_release(release_mid_sem);
214 check_rtems_status(status, 0, "rtems_semaphore_release RMID");
218 printf("1 going to release SHI\n");
219 status=rtems_semaphore_release(shared_with_hi_sem);
220 check_rtems_status(status, 0, "rtems_semaphore_release SHI");
222 status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
223 check_rtems_status( status, 0, "rtems_task_set_priority");
224 printf("1 priority is %d\n", (int)prio);
228 printf("1 going to release SLO\n");
229 status=rtems_semaphore_release(shared_with_lo_sem);
230 check_rtems_status(status, 0, "rtems_semaphore_release SLO");
231 printf("1 released both SHI and SLO\n");
233 status = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio);
234 check_rtems_status( status, 0, "rtems_task_set_priority");
235 printf("1 priority is %d\n", (int)prio);
239 printf("1 going to sleep\n");
240 status = rtems_task_wake_after( TICKS_PER_SECOND );
241 check_rtems_status( status, 0, "rtems_task_wake_after" );