source: rtems/cpukit/score/src/threadmp.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 *  Multiprocessing Support for the Thread Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/core/priority.h>
18#include <rtems/core/thread.h>
19#include <rtems/core/wkspace.h>
20#include <rtems/core/isr.h>
21
22/*PAGE
23 *
24 *  _Thread_MP_Handler_initialization
25 *
26 */
27
28void _Thread_MP_Handler_initialization (
29  unsigned32  maximum_proxies
30)
31{
32
33  _Chain_Initialize_empty( &_Thread_MP_Active_proxies );
34
35  if ( maximum_proxies == 0 ) {
36    _Chain_Initialize_empty( &_Thread_MP_Inactive_proxies );
37    return;
38  }
39
40
41  _Chain_Initialize(
42    &_Thread_MP_Inactive_proxies,
43    _Workspace_Allocate_or_fatal_error(
44      maximum_proxies * sizeof( Thread_Proxy_control )
45    ),
46    maximum_proxies,
47    sizeof( Thread_Proxy_control )
48  );
49
50}
51
52/*PAGE
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 = _Thread_MP_Receive->receive_packet;
74
75    the_proxy->Object.id = _Thread_MP_Receive->receive_packet->source_tid;
76
77    the_proxy->current_priority =
78      _Thread_MP_Receive->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 insures that the compiler will
97   *        think that all paths return a value.
98   */
99
100  return NULL;
101}
102
103/*PAGE
104 *
105 *  _Thread_MP_Find_proxy
106 *
107 */
108
109/*
110 *  The following macro provides the offset of the Active element
111 *  in the Thread_Proxy_control structure.  This is the logical
112 *  equivalent of the POSITION attribute in Ada.
113 */
114
115#define _Thread_MP_Proxy_Active_offset \
116     ((unsigned32)&(((Thread_Proxy_control *)0))->Active)
117
118Thread_Control *_Thread_MP_Find_proxy (
119  Objects_Id  the_id
120)
121{
122
123  Chain_Node           *proxy_node;
124  Thread_Control       *the_thread;
125  ISR_Level             level;
126
127restart:
128
129  _ISR_Disable( level );
130
131    for (  proxy_node = _Thread_MP_Active_proxies.first;
132           !_Chain_Is_tail( &_Thread_MP_Active_proxies, proxy_node ) ;
133        ) {
134
135      the_thread = _Addresses_Subtract_offset(
136                     proxy_node,
137                     _Thread_MP_Proxy_Active_offset
138                   );
139
140      if ( _Objects_Are_ids_equal( the_thread->Object.id, the_id ) ) {
141        _ISR_Enable( level );
142        return the_thread;
143      }
144
145      _ISR_Flash( level );
146
147      proxy_node = proxy_node->next;
148
149      /*
150       *  A proxy which is only dormant is not in a blocking state.
151       *  Therefore, we are looking at proxy which has been moved from
152       *  active to inactive chain (by an ISR) and need to restart
153       *  the search.
154       */
155
156      if ( _States_Is_only_dormant( the_thread->current_state ) ) {
157        _ISR_Enable( level );
158        goto restart;
159      }
160    }
161
162  _ISR_Enable( level );
163  return NULL;
164}
Note: See TracBrowser for help on using the repository browser.