From adf98bd423cabd47466b13d3432284da0d532176 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 21 Feb 1996 14:44:11 +0000 Subject: Removed the internal thread objects and dispersed its contents to the thread handler (IDLE), MPCI object (SYSI now MP Receive) and initialize_executive_early (IO initialization). The SYSI task no longer exists in a single processor configuration. This reduces single processor Workspace requirements by a TCB and a stack which is often larger than the minimum stack size. Moving the IO initialization plus accompanying BSP hooks eliminated an initialization ordering problem in which a global task could be created before the MPCI was initialized. --- cpukit/score/src/mpci.c | 183 +++++++++++++++++++++++++++++++++++++++++++++- cpukit/score/src/thread.c | 110 ++++++++++++++++++++++++++-- 2 files changed, 286 insertions(+), 7 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 08b8eff9ba..c3090aacc1 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -50,6 +50,22 @@ void _MPCI_Handler_initialization( _MPCI_table = users_mpci_table; + if ( !_System_state_Is_multiprocessing ) + return; + + /* + * Register the MP Process Packet routine. + */ + + _MPCI_Register_packet_processor( + MP_PACKET_MPCI_INTERNAL, + _MPCI_Internal_packets_Process_packet + ); + + /* + * Create the counting semaphore used by the MPCI Receive Server. + */ + attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( @@ -70,6 +86,49 @@ void _MPCI_Handler_initialization( ); } +/*PAGE + * + * _MPCI_Create_server + * + * This subprogram creates the MPCI receive server. + */ + +char *_MPCI_Internal_name = "MPCI"; + +void _MPCI_Create_server( void ) +{ + + if ( !_System_state_Is_multiprocessing ) + return; + + /* + * Initialize the MPCI Receive Server + */ + + _MPCI_Receive_server_tcb = _Thread_Internal_allocate(); + + _Thread_Initialize( + &_Thread_Internal_information, + _MPCI_Receive_server_tcb, + NULL, /* allocate the stack */ + MPCI_RECEIVE_SERVER_STACK_SIZE, + CPU_ALL_TASKS_ARE_FP, + PRIORITY_MINIMUM, + FALSE, /* no preempt */ + FALSE, /* not timesliced */ + 0, /* all interrupts enabled */ + _MPCI_Internal_name + ); + + _Thread_Start( + _MPCI_Receive_server_tcb, + THREAD_START_NUMERIC, + _MPCI_Receive_server, + NULL, + 0 + ); +} + /*PAGE * * _MPCI_Initialization @@ -286,7 +345,9 @@ Thread_Control *_MPCI_Process_response ( * */ -void _MPCI_Receive_server( void ) +Thread _MPCI_Receive_server( + unsigned32 ignored +) { MP_packet_Prefix *the_packet; @@ -294,7 +355,6 @@ void _MPCI_Receive_server( void ) Thread_Control *executing; executing = _Thread_Executing; - _MPCI_Receive_server_tcb = executing; for ( ; ; ) { @@ -342,4 +402,123 @@ void _MPCI_Announce ( void ) _Thread_Enable_dispatch(); } +/*PAGE + * + * _MPCI_Internal_packets_Send_process_packet + * + */ + +void _MPCI_Internal_packets_Send_process_packet ( + MPCI_Internal_Remote_operations operation +) +{ + MPCI_Internal_packet *the_packet; + + switch ( operation ) { + + case MPCI_PACKETS_SYSTEM_VERIFY: + + the_packet = _MPCI_Internal_packets_Get_packet(); + the_packet->Prefix.the_class = MP_PACKET_MPCI_INTERNAL; + the_packet->Prefix.length = sizeof ( MPCI_Internal_packet ); + the_packet->Prefix.to_convert = sizeof ( MPCI_Internal_packet ); + the_packet->operation = operation; + + the_packet->maximum_nodes = _Objects_Maximum_nodes; + + the_packet->maximum_global_objects = _Objects_MP_Maximum_global_objects; + + _MPCI_Send_process_packet( MPCI_ALL_NODES, &the_packet->Prefix ); + break; + } +} + +/*PAGE + * + * _MPCI_Internal_packets_Send_request_packet + * + * This subprogram is not needed since there are no request + * packets to be sent by this manager. + * + */ + +/*PAGE + * + * _MPCI_Internal_packets_Send_response_packet + * + * This subprogram is not needed since there are no response + * packets to be sent by this manager. + * + */ + +/*PAGE + * + * + * _MPCI_Internal_packets_Process_packet + * + */ + +void _MPCI_Internal_packets_Process_packet ( + MP_packet_Prefix *the_packet_prefix +) +{ + MPCI_Internal_packet *the_packet; + unsigned32 maximum_nodes; + unsigned32 maximum_global_objects; + + the_packet = (MPCI_Internal_packet *) the_packet_prefix; + + switch ( the_packet->operation ) { + + case MPCI_PACKETS_SYSTEM_VERIFY: + + maximum_nodes = the_packet->maximum_nodes; + maximum_global_objects = the_packet->maximum_global_objects; + if ( maximum_nodes != _Objects_Maximum_nodes || + maximum_global_objects != _Objects_MP_Maximum_global_objects ) { + + _MPCI_Return_packet( the_packet_prefix ); + + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION + ); + } + + _MPCI_Return_packet( the_packet_prefix ); + + break; + } +} + +/*PAGE + * + * _MPCI_Internal_packets_Send_object_was_deleted + * + * This subprogram is not needed since there are no objects + * deleted by this manager. + * + */ + +/*PAGE + * + * _MPCI_Internal_packets_Send_extract_proxy + * + * This subprogram is not needed since there are no objects + * deleted by this manager. + * + */ + +/*PAGE + * + * _MPCI_Internal_packets_Get_packet + * + */ + +MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ) +{ + return ( (MPCI_Internal_packet *) _MPCI_Get_packet() ); +} + /* end of file */ diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c index 1214b9141e..258fcb92bd 100644 --- a/cpukit/score/src/thread.c +++ b/cpukit/score/src/thread.c @@ -40,13 +40,15 @@ * Output parameters: NONE */ +char *_Thread_Idle_name = "IDLE"; + void _Thread_Handler_initialization( unsigned32 ticks_per_timeslice, unsigned32 maximum_extensions, unsigned32 maximum_proxies ) { - unsigned32 index; + unsigned32 index; _Context_Switch_necessary = FALSE; _Thread_Executing = NULL; @@ -66,6 +68,83 @@ void _Thread_Handler_initialization( _Chain_Initialize_empty( &_Thread_Ready_chain[ index ] ); _Thread_MP_Handler_initialization( maximum_proxies ); + + /* + * Initialize this class of objects. + */ + + _Objects_Initialize_information( + &_Thread_Internal_information, + OBJECTS_INTERNAL_THREADS, + FALSE, + ( _System_state_Is_multiprocessing ) ? 2 : 1, + sizeof( Thread_Control ), + TRUE, + 8, + TRUE + ); + +} + +/*PAGE + * + * _Thread_Create_idle + */ + +void _Thread_Create_idle( void ) +{ + Thread (*idle); + + /* + * The entire workspace is zeroed during its initialization. Thus, all + * fields not explicitly assigned were explicitly zeroed by + * _Workspace_Initialization. + */ + + _Thread_Idle = _Thread_Internal_allocate(); + + /* + * Initialize the IDLE task. + */ + +#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) + idle = _CPU_Thread_Idle_body; +#else + idle = _Thread_Idle_body; +#endif + + if ( _CPU_Table.idle_task ) + idle = _CPU_Table.idle_task; + + _Thread_Initialize( + &_Thread_Internal_information, + _Thread_Idle, + NULL, /* allocate the stack */ + THREAD_IDLE_STACK_SIZE, + CPU_IDLE_TASK_IS_FP, + PRIORITY_MAXIMUM, + TRUE, /* preemptable */ + FALSE, /* not timesliced */ + 0, /* all interrupts enabled */ + _Thread_Idle_name + ); + + /* + * WARNING!!! This is necessary to "kick" start the system and + * MUST be done before _Thread_Start is invoked. + */ + + _Thread_Heir = + _Thread_Executing = _Thread_Idle; + + _Thread_Start( + _Thread_Idle, + THREAD_START_NUMERIC, + idle, + NULL, + 0 + ); + } /*PAGE @@ -89,10 +168,7 @@ void _Thread_Handler_initialization( * select heir */ -void _Thread_Start_multitasking( - Thread_Control *system_thread, - Thread_Control *idle_thread -) +void _Thread_Start_multitasking( void ) { /* * The system is now multitasking and completely initialized. @@ -1068,4 +1144,28 @@ STATIC INLINE Thread_Control *_Thread_Get ( return (Thread_Control *) _Objects_Get( information, id, location ); } + +/*PAGE + * + * _Thread_Idle_body + * + * This kernel routine is the idle thread. The idle thread runs any time + * no other thread is ready to run. This thread loops forever with + * interrupts enabled. + * + * Input parameters: + * ignored - this parameter is ignored + * + * Output parameters: NONE + */ + +#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE) +Thread _Thread_Idle_body( + unsigned32 ignored +) +{ + for( ; ; ) ; +} +#endif + #endif -- cgit v1.2.3