source: rtems/cpukit/rtems/src/taskmp.c @ f5d6c8b

4.115
Last change on this file since f5d6c8b was f5d6c8b, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/15 at 14:25:52

score: Delete Thread_queue_Control::timeout_status

Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.

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