source: rtems/cpukit/rtems/src/taskmp.c @ 98e4ebf

4.104.114.84.95
Last change on this file since 98e4ebf was 98e4ebf, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 8, 1997 at 3:45:54 PM

Fixed typo in the pointer to the license terms.

  • Property mode set to 100644
File size: 8.6 KB
Line 
1/*
2 *  Multiprocessing Support for the RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1997.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/rtems/status.h>
18#include <rtems/score/mpci.h>
19#include <rtems/score/mppkt.h>
20#include <rtems/score/object.h>
21#include <rtems/rtems/options.h>
22#include <rtems/rtems/tasks.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/watchdog.h>
25#include <rtems/rtems/support.h>
26
27/*PAGE
28 *
29 *  _RTEMS_tasks_MP_Send_process_packet
30 *
31 */
32
33void _RTEMS_tasks_MP_Send_process_packet (
34  RTEMS_tasks_MP_Remote_operations operation,
35  Objects_Id                       task_id,
36  rtems_name                       name
37)
38{
39  RTEMS_tasks_MP_Packet *the_packet;
40
41  switch ( operation ) {
42
43    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
44    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
45
46      the_packet                    = _RTEMS_tasks_MP_Get_packet();
47      the_packet->Prefix.the_class  = MP_PACKET_TASKS;
48      the_packet->Prefix.length     = sizeof ( RTEMS_tasks_MP_Packet );
49      the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
50      the_packet->operation         = operation;
51      the_packet->Prefix.id         = task_id;
52      the_packet->name              = name;
53
54      _MPCI_Send_process_packet( MPCI_ALL_NODES, &the_packet->Prefix );
55      break;
56
57    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
58    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
59    case RTEMS_TASKS_MP_RESUME_REQUEST:
60    case RTEMS_TASKS_MP_RESUME_RESPONSE:
61    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
62    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
63    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
64    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
65    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
66    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
67      break;
68  }
69}
70
71/*PAGE
72 *
73 *  _RTEMS_tasks_MP_Send_request_packet
74 *
75 */
76
77rtems_status_code _RTEMS_tasks_MP_Send_request_packet (
78  RTEMS_tasks_MP_Remote_operations operation,
79  Objects_Id                       task_id,
80  rtems_task_priority                 new_priority,
81  unsigned32                       notepad,
82  unsigned32                       note
83)
84{
85  RTEMS_tasks_MP_Packet *the_packet;
86
87  switch ( operation ) {
88
89    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
90    case RTEMS_TASKS_MP_RESUME_REQUEST:
91    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
92    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
93    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
94
95      the_packet                    = _RTEMS_tasks_MP_Get_packet();
96      the_packet->Prefix.the_class  = MP_PACKET_TASKS;
97      the_packet->Prefix.length     = sizeof ( RTEMS_tasks_MP_Packet );
98      the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
99      the_packet->operation         = operation;
100      the_packet->Prefix.id         = task_id;
101      the_packet->the_priority      = new_priority;
102      the_packet->notepad           = notepad;
103      the_packet->note              = note;
104
105      return _MPCI_Send_request_packet(
106        rtems_get_node( task_id ),
107        &the_packet->Prefix,
108        STATES_READY     /* Not used */
109      );
110      break;
111
112    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
113    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
114    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
115    case RTEMS_TASKS_MP_RESUME_RESPONSE:
116    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
117    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
118    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
119      break;
120
121  }
122  /*
123   *  The following line is included to satisfy compilers which
124   *  produce warnings when a function does not end with a return.
125   */
126  return RTEMS_SUCCESSFUL;
127}
128
129/*PAGE
130 *
131 *  _RTEMS_tasks_MP_Send_response_packet
132 *
133 */
134
135void _RTEMS_tasks_MP_Send_response_packet (
136  RTEMS_tasks_MP_Remote_operations  operation,
137  Thread_Control                   *the_thread
138)
139{
140  RTEMS_tasks_MP_Packet *the_packet;
141
142  switch ( operation ) {
143
144    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
145    case RTEMS_TASKS_MP_RESUME_RESPONSE:
146    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
147    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
148    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
149
150      the_packet = (RTEMS_tasks_MP_Packet *) the_thread->receive_packet;
151
152/*
153 *  The packet being returned already contains the class, length, and
154 *  to_convert fields, therefore they are not set in this routine.
155 */
156      the_packet->operation    = operation;
157      the_packet->Prefix.id    = the_packet->Prefix.source_tid;
158
159      _MPCI_Send_response_packet(
160        rtems_get_node( the_packet->Prefix.source_tid ),
161        &the_packet->Prefix
162      );
163      break;
164
165    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
166    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
167    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
168    case RTEMS_TASKS_MP_RESUME_REQUEST:
169    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
170    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
171    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
172      break;
173
174  }
175}
176
177/*PAGE
178 *
179 *
180 *  _RTEMS_tasks_MP_Process_packet
181 *
182 */
183
184void _RTEMS_tasks_MP_Process_packet (
185  rtems_packet_prefix  *the_packet_prefix
186)
187{
188  RTEMS_tasks_MP_Packet *the_packet;
189  Thread_Control   *the_thread;
190  boolean           ignored;
191
192  the_packet = (RTEMS_tasks_MP_Packet *) the_packet_prefix;
193
194  switch ( the_packet->operation ) {
195
196    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
197
198      ignored = _Objects_MP_Allocate_and_open(
199                  &_RTEMS_tasks_Information,
200                  the_packet->name,
201                  the_packet->Prefix.id,
202                  TRUE
203                );
204
205      _MPCI_Return_packet( the_packet_prefix );
206      break;
207
208    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
209
210      _Objects_MP_Close( &_RTEMS_tasks_Information, the_packet->Prefix.id );
211
212      _MPCI_Return_packet( the_packet_prefix );
213      break;
214
215    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
216
217      the_packet->Prefix.return_code = rtems_task_suspend(
218        the_packet->Prefix.id
219      );
220
221      _RTEMS_tasks_MP_Send_response_packet(
222        RTEMS_TASKS_MP_SUSPEND_RESPONSE,
223        _Thread_Executing
224      );
225      break;
226
227    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
228    case RTEMS_TASKS_MP_RESUME_RESPONSE:
229    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
230
231      the_thread = _MPCI_Process_response( the_packet_prefix );
232
233      _MPCI_Return_packet( the_packet_prefix );
234      break;
235
236    case RTEMS_TASKS_MP_RESUME_REQUEST:
237
238      the_packet->Prefix.return_code = rtems_task_resume(
239        the_packet->Prefix.id
240      );
241
242      _RTEMS_tasks_MP_Send_response_packet(
243        RTEMS_TASKS_MP_RESUME_RESPONSE,
244        _Thread_Executing
245      );
246      break;
247
248    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
249
250      the_packet->Prefix.return_code = rtems_task_set_priority(
251        the_packet->Prefix.id,
252        the_packet->the_priority,
253        &the_packet->the_priority
254      );
255
256      _RTEMS_tasks_MP_Send_response_packet(
257        RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE,
258        _Thread_Executing
259      );
260      break;
261
262    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
263
264      the_thread = _MPCI_Process_response( the_packet_prefix );
265
266      *(rtems_task_priority *)the_thread->Wait.return_argument =
267                                               the_packet->the_priority;
268
269      _MPCI_Return_packet( the_packet_prefix );
270      break;
271
272    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
273
274      the_packet->Prefix.return_code = rtems_task_get_note(
275        the_packet->Prefix.id,
276        the_packet->notepad,
277        &the_packet->note
278      );
279
280      _RTEMS_tasks_MP_Send_response_packet(
281        RTEMS_TASKS_MP_GET_NOTE_RESPONSE,
282        _Thread_Executing
283      );
284      break;
285
286    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
287
288      the_thread = _MPCI_Process_response( the_packet_prefix );
289
290      *(unsigned32 *)the_thread->Wait.return_argument = the_packet->note;
291
292      _MPCI_Return_packet( the_packet_prefix );
293      break;
294
295    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
296
297      the_packet->Prefix.return_code = rtems_task_set_note(
298        the_packet->Prefix.id,
299        the_packet->notepad,
300        the_packet->note
301      );
302
303      _RTEMS_tasks_MP_Send_response_packet(
304        RTEMS_TASKS_MP_SET_NOTE_RESPONSE,
305        _Thread_Executing
306      );
307      break;
308  }
309}
310
311/*PAGE
312 *
313 *  _RTEMS_tasks_MP_Send_object_was_deleted
314 *
315 *  This routine is not neededby the Tasks since a task
316 *  cannot be globally deleted.
317 *
318 */
319
320/*PAGE
321 *
322 *  _RTEMS_tasks_MP_Send_extract_proxy
323 *
324 *  This routine is not neededby the Tasks since a task
325 *  cannot be globally deleted.
326 *
327 */
328
329/*PAGE
330 *
331 *  _RTEMS_tasks_MP_Get_packet
332 *
333 */
334
335RTEMS_tasks_MP_Packet *_RTEMS_tasks_MP_Get_packet ( void )
336{
337  return (RTEMS_tasks_MP_Packet *) _MPCI_Get_packet();
338}
339
340/* end of file */
Note: See TracBrowser for help on using the repository browser.