RTEMS
userextaddset.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-2007.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
23 #include <rtems/score/smp.h>
24 #include <rtems/score/percpu.h>
25 
26 static void _User_extensions_Set_ancestors( void )
27 {
28 #if defined(RTEMS_SMP)
30  uint32_t cpu_max;
31  uint32_t cpu_index;
32 
33  cpu_max = _SMP_Get_processor_maximum();
34 
35  for ( cpu_index = 0 ; cpu_index < cpu_max ; ++cpu_index ) {
36  Per_CPU_Control *cpu;
37 
38  cpu = _Per_CPU_Get_by_index( cpu_index );
39  cpu->ancestor = cpu->executing;
40  }
41  }
42 #endif
43 }
44 
46  User_extensions_Control *the_extension
47 )
48 {
49  ISR_lock_Context lock_context;
50 
51  _User_extensions_Acquire( &lock_context );
52  _Chain_Initialize_node( &the_extension->Node );
55  &the_extension->Node
56  );
57  _User_extensions_Release( &lock_context );
58 
59  /*
60  * If a switch handler is present, append it to the switch chain.
61  */
62 
63  if ( the_extension->Callouts.thread_switch != NULL ) {
64  the_extension->Switch.thread_switch =
65  the_extension->Callouts.thread_switch;
66 
67  _Per_CPU_Acquire_all( &lock_context );
68  _User_extensions_Set_ancestors();
69  _Chain_Initialize_node( &the_extension->Switch.Node );
72  &the_extension->Switch.Node
73  );
74  _Per_CPU_Release_all( &lock_context );
75  }
76 }
struct _Thread_Control * executing
This is the thread executing on this processor.
Definition: percpu.h:420
static __inline__ void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
Chain_Control _User_extensions_Switches_list
List of active task switch extensions.
struct _Thread_Control * ancestor
The ancestor of the executing thread.
Definition: percpu.h:536
User Extension Handler API.
SuperCore SMP Support API.
static __inline__ void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
User_extensions_List _User_extensions_List
List of active extensions.
Per CPU Core Structure.
Definition: percpu.h:347
void _User_extensions_Add_set(User_extensions_Control *the_extension)
Adds a user extension.
Definition: userextaddset.c:45
static void _User_extensions_Release(ISR_lock_Context *lock_context)
Releases the lock context and enables interrupts.
Definition: userextimpl.h:486
Manages each user extension set.
Definition: userextdata.h:50
Chain_Control Active
Active dynamically added user extensions.
Definition: userextimpl.h:55
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
static void _User_extensions_Acquire(ISR_lock_Context *lock_context)
Disables interrupts and acquires the lock context.
Definition: userextimpl.h:473
static __inline__ bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
Definition: chainimpl.h:393