source: rtems/cpukit/score/src/threadmp.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  Multiprocessing Support for the Thread Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2006.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/score/priority.h>
19#include <rtems/score/thread.h>
20#include <rtems/score/mpci.h>
21#include <rtems/score/wkspace.h>
22#include <rtems/score/isr.h>
23
24/*
25 *  _Thread_MP_Handler_initialization
26 *
27 */
28
29void _Thread_MP_Handler_initialization (
30  uint32_t    maximum_proxies
31)
32{
33
34  _Chain_Initialize_empty( &_Thread_MP_Active_proxies );
35
36  if ( maximum_proxies == 0 ) {
37    _Chain_Initialize_empty( &_Thread_MP_Inactive_proxies );
38    return;
39  }
40
41
42  _Chain_Initialize(
43    &_Thread_MP_Inactive_proxies,
44    _Workspace_Allocate_or_fatal_error(
45      maximum_proxies * sizeof( Thread_Proxy_control )
46    ),
47    maximum_proxies,
48    sizeof( Thread_Proxy_control )
49  );
50
51}
52
53/*
54 *  _Thread_MP_Allocate_proxy
55 *
56 */
57
58Thread_Control *_Thread_MP_Allocate_proxy (
59  States_Control  the_state
60)
61{
62  Thread_Control       *the_thread;
63  Thread_Proxy_control *the_proxy;
64
65  the_thread = (Thread_Control *)_Chain_Get( &_Thread_MP_Inactive_proxies );
66
67  if ( !_Thread_Is_null( the_thread ) ) {
68
69    the_proxy = (Thread_Proxy_control *) the_thread;
70
71    _Thread_Executing->Wait.return_code = THREAD_STATUS_PROXY_BLOCKING;
72
73    the_proxy->receive_packet = _MPCI_Receive_server_tcb->receive_packet;
74
75    the_proxy->Object.id = _MPCI_Receive_server_tcb->receive_packet->source_tid;
76
77    the_proxy->current_priority =
78      _MPCI_Receive_server_tcb->receive_packet->source_priority;
79
80    the_proxy->current_state = _States_Set( STATES_DORMANT, the_state );
81
82    the_proxy->Wait = _Thread_Executing->Wait;
83
84    _Chain_Append( &_Thread_MP_Active_proxies, &the_proxy->Active );
85
86    return the_thread;
87  }
88
89  _Internal_error_Occurred(
90    INTERNAL_ERROR_CORE,
91    true,
92    INTERNAL_ERROR_OUT_OF_PROXIES
93  );
94
95  /*
96   *  NOTE: The following return ensures that the compiler will
97   *        think that all paths return a value.
98   */
99
100  return NULL;
101}
102
103/*
104 *  _Thread_MP_Find_proxy
105 *
106 */
107
108/*
109 *  The following macro provides the offset of the Active element
110 *  in the Thread_Proxy_control structure.  This is the logical
111 *  equivalent of the POSITION attribute in Ada.
112 */
113
114#define _Thread_MP_Proxy_Active_offset \
115     ((uint32_t)&(((Thread_Proxy_control *)0))->Active)
116
117Thread_Control *_Thread_MP_Find_proxy (
118  Objects_Id  the_id
119)
120{
121
122  Chain_Node           *proxy_node;
123  Thread_Control       *the_thread;
124  ISR_Level             level;
125
126restart:
127
128  _ISR_Disable( level );
129
130    for (  proxy_node = _Chain_First( &_Thread_MP_Active_proxies );
131           !_Chain_Is_tail( &_Thread_MP_Active_proxies, proxy_node ) ;
132        ) {
133
134      the_thread = (Thread_Control *) _Addresses_Subtract_offset(
135                     proxy_node,
136                     _Thread_MP_Proxy_Active_offset
137                   );
138
139      if ( _Objects_Are_ids_equal( the_thread->Object.id, the_id ) ) {
140        _ISR_Enable( level );
141        return the_thread;
142      }
143
144      _ISR_Flash( level );
145
146      proxy_node = _Chain_Next( proxy_node );
147
148      /*
149       *  A proxy which is only dormant is not in a blocking state.
150       *  Therefore, we are looking at proxy which has been moved from
151       *  active to inactive chain (by an ISR) and need to restart
152       *  the search.
153       */
154
155      if ( _States_Is_only_dormant( the_thread->current_state ) ) {
156        _ISR_Enable( level );
157        goto restart;
158      }
159    }
160
161  _ISR_Enable( level );
162  return NULL;
163}
Note: See TracBrowser for help on using the repository browser.