From 3a5dbdca1b37bacc18fe61701530d28c6f1254ee Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 31 Jul 1995 22:22:38 +0000 Subject: Switched to events for mp receive server and eliminated the special blocking mechanism for it. --- c/src/exec/rtems/src/mp.c | 67 ++++++++++++++++------- c/src/exec/score/headers/mppkt.h | 2 +- c/src/exec/score/headers/threadmp.h | 20 ------- c/src/exec/score/include/rtems/score/mppkt.h | 2 +- c/src/exec/score/include/rtems/score/threadmp.h | 20 ------- c/src/exec/score/src/thread.c | 3 +- c/src/exec/score/src/threadmp.c | 70 ------------------------- cpukit/rtems/src/mp.c | 67 ++++++++++++++++------- cpukit/score/include/rtems/score/mppkt.h | 2 +- cpukit/score/include/rtems/score/threadmp.h | 20 ------- cpukit/score/src/thread.c | 3 +- cpukit/score/src/threadmp.c | 70 ------------------------- 12 files changed, 105 insertions(+), 241 deletions(-) diff --git a/c/src/exec/rtems/src/mp.c b/c/src/exec/rtems/src/mp.c index f9522b2296..a6b6dad8ba 100644 --- a/c/src/exec/rtems/src/mp.c +++ b/c/src/exec/rtems/src/mp.c @@ -55,7 +55,13 @@ void _Multiprocessing_Manager_initialization ( void ) void rtems_multiprocessing_announce ( void ) { - _Thread_MP_Ready(); + _Thread_Disable_dispatch(); + _Event_sets_Post( + RTEMS_EVENT_0, + &_Internal_threads_System_initialization_thread->pending_events + ); + _Event_Surrender( _Internal_threads_System_initialization_thread ); + _Thread_Enable_dispatch(); } /*PAGE @@ -64,63 +70,88 @@ void rtems_multiprocessing_announce ( void ) * */ +typedef void (*packet_processor)( rtems_packet_prefix * ); + +packet_processor _Multiprocessor_Packet_processors[] = { + _Internal_threads_MP_Process_packet, /* RTEMS_MP_PACKET_INTERNAL_THREADS */ + _RTEMS_tasks_MP_Process_packet, /* RTEMS_MP_PACKET_TASKS */ + _Message_queue_MP_Process_packet, /* RTEMS_MP_PACKET_MESSAGE_QUEUE */ + _Semaphore_MP_Process_packet, /* RTEMS_MP_PACKET_SEMAPHORE */ + _Partition_MP_Process_packet, /* RTEMS_MP_PACKET_PARTITION */ + 0, /* RTEMS_MP_PACKET_REGION */ + _Event_MP_Process_packet, /* RTEMS_MP_PACKET_EVENT */ + _Signal_MP_Process_packet /* RTEMS_MP_PACKET_SIGNAL */ +}; + Thread _Multiprocessing_Receive_server ( Thread_Argument ignored ) { rtems_packet_prefix *the_packet; - - _Thread_Dispatch_disable_level = 1; + packet_processor the_function; for ( ; ; ) { - _Internal_threads_System_initialization_thread->Notepads[ 0 ] = 1; + _Thread_Disable_dispatch(); + _Event_Seize( RTEMS_EVENT_0, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); + _Thread_Enable_dispatch(); - the_packet = _MPCI_Receive_packet(); + for ( ; ; ) { + the_packet = _MPCI_Receive_packet(); - if ( ! the_packet ) { - _Thread_MP_Block(); - _Thread_Dispatch_disable_level = 1; - } - else { + if ( !the_packet ) + break; _Thread_Executing->receive_packet = the_packet; - switch ( the_packet->the_class ) { + if ( !_Mp_packet_Is_valid_packet_class ( the_packet->the_class ) ) + break; + + the_function = _Multiprocessor_Packet_processors[ the_packet->the_class ]; + + if ( !the_function ) + break; + (*the_function)( the_packet ); +#if 0 + switch ( the_packet->the_class ) { + case RTEMS_MP_PACKET_INTERNAL_THREADS: _Internal_threads_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_TASKS: _RTEMS_tasks_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_MESSAGE_QUEUE: _Message_queue_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_SEMAPHORE: _Semaphore_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_PARTITION: _Partition_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_REGION: /* Global regions are unsupported at this time */ break; - + case RTEMS_MP_PACKET_EVENT: _Event_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_SIGNAL: _Signal_MP_Process_packet( the_packet ); break; } +#endif + + } } } diff --git a/c/src/exec/score/headers/mppkt.h b/c/src/exec/score/headers/mppkt.h index e0cf6b1967..4e72d6930a 100644 --- a/c/src/exec/score/headers/mppkt.h +++ b/c/src/exec/score/headers/mppkt.h @@ -38,7 +38,7 @@ extern "C" { typedef enum { RTEMS_MP_PACKET_INTERNAL_THREADS = 0, - RTEMS_MP_PACKET_TASKS = 1, + RTEMS_MP_PACKET_TASKS = 1, RTEMS_MP_PACKET_MESSAGE_QUEUE = 2, RTEMS_MP_PACKET_SEMAPHORE = 3, RTEMS_MP_PACKET_PARTITION = 4, diff --git a/c/src/exec/score/headers/threadmp.h b/c/src/exec/score/headers/threadmp.h index c6e8252030..db94a65d78 100644 --- a/c/src/exec/score/headers/threadmp.h +++ b/c/src/exec/score/headers/threadmp.h @@ -89,26 +89,6 @@ Thread_Control *_Thread_MP_Find_proxy ( Objects_Id the_id ); -/* - * _Thread_MP_Block - * - * DESCRIPTION: - * - * This routine blocks the MP Receive server thread. - */ - -void _Thread_MP_Block( void ); - -/* - * _Thread_MP_Ready - * - * DESCRIPTION: - * - * This routine readies the MP Receive server thread. - */ - -void _Thread_MP_Ready( void ); - /* * The following is used to determine when the multiprocessing receive * thread is executing so that a proxy can be allocated instead of diff --git a/c/src/exec/score/include/rtems/score/mppkt.h b/c/src/exec/score/include/rtems/score/mppkt.h index e0cf6b1967..4e72d6930a 100644 --- a/c/src/exec/score/include/rtems/score/mppkt.h +++ b/c/src/exec/score/include/rtems/score/mppkt.h @@ -38,7 +38,7 @@ extern "C" { typedef enum { RTEMS_MP_PACKET_INTERNAL_THREADS = 0, - RTEMS_MP_PACKET_TASKS = 1, + RTEMS_MP_PACKET_TASKS = 1, RTEMS_MP_PACKET_MESSAGE_QUEUE = 2, RTEMS_MP_PACKET_SEMAPHORE = 3, RTEMS_MP_PACKET_PARTITION = 4, diff --git a/c/src/exec/score/include/rtems/score/threadmp.h b/c/src/exec/score/include/rtems/score/threadmp.h index c6e8252030..db94a65d78 100644 --- a/c/src/exec/score/include/rtems/score/threadmp.h +++ b/c/src/exec/score/include/rtems/score/threadmp.h @@ -89,26 +89,6 @@ Thread_Control *_Thread_MP_Find_proxy ( Objects_Id the_id ); -/* - * _Thread_MP_Block - * - * DESCRIPTION: - * - * This routine blocks the MP Receive server thread. - */ - -void _Thread_MP_Block( void ); - -/* - * _Thread_MP_Ready - * - * DESCRIPTION: - * - * This routine readies the MP Receive server thread. - */ - -void _Thread_MP_Ready( void ); - /* * The following is used to determine when the multiprocessing receive * thread is executing so that a proxy can be allocated instead of diff --git a/c/src/exec/score/src/thread.c b/c/src/exec/score/src/thread.c index a181780e52..9c9a7691c8 100644 --- a/c/src/exec/score/src/thread.c +++ b/c/src/exec/score/src/thread.c @@ -316,7 +316,8 @@ void _Thread_Clear_state( if ( the_thread->current_priority < _Thread_Heir->current_priority ) { _Thread_Heir = the_thread; - if ( _Modes_Is_preempt( _Thread_Executing->current_modes ) ) + if ( _Modes_Is_preempt( _Thread_Executing->current_modes ) || + the_thread->current_priority == 0 ) _Context_Switch_necessary = TRUE; } } diff --git a/c/src/exec/score/src/threadmp.c b/c/src/exec/score/src/threadmp.c index 5d352e2d25..f2b78cd8cd 100644 --- a/c/src/exec/score/src/threadmp.c +++ b/c/src/exec/score/src/threadmp.c @@ -157,73 +157,3 @@ restart: _ISR_Enable( level ); return NULL; } - -/*PAGE - * - * _Thread_MP_Block - * - */ - -void _Thread_MP_Block( void ) -{ - ISR_Level level; - - _ISR_Disable( level ); - - if ( _Thread_MP_Receive->Notepads[ 0 ] != 0 ) { - _Priority_Remove_from_bit_map( &_Thread_MP_Receive->Priority_map ); - - _Thread_MP_Receive->current_state = STATES_SUSPENDED; - - _ISR_Flash( level ); - - _Thread_Calculate_heir(); - - _Context_Switch_necessary = TRUE; - - _ISR_Enable( level ); - - _Thread_Dispatch_disable_level = 0; - - _Thread_Dispatch(); - - return; - - } - _ISR_Enable( level ); - -} - -/*PAGE - * - * _Thread_MP_Ready - * - */ - -void _Thread_MP_Ready( void ) -{ - ISR_Level level; - - _ISR_Disable( level ); - - if ( _States_Is_suspended( _Thread_MP_Receive->current_state ) ) { - _Priority_Add_to_bit_map( &_Thread_MP_Receive->Priority_map ); - - _Thread_MP_Receive->current_state = STATES_READY; - - _Thread_Heir = _Thread_MP_Receive; - - _Context_Switch_necessary = TRUE; - - _ISR_Enable( level ); - - if ( _Thread_Is_dispatching_enabled() ) - _Thread_Dispatch(); - - } else { - - _Thread_MP_Receive->Notepads[ 0 ] = 0; - _ISR_Enable( level ); - - } -} diff --git a/cpukit/rtems/src/mp.c b/cpukit/rtems/src/mp.c index f9522b2296..a6b6dad8ba 100644 --- a/cpukit/rtems/src/mp.c +++ b/cpukit/rtems/src/mp.c @@ -55,7 +55,13 @@ void _Multiprocessing_Manager_initialization ( void ) void rtems_multiprocessing_announce ( void ) { - _Thread_MP_Ready(); + _Thread_Disable_dispatch(); + _Event_sets_Post( + RTEMS_EVENT_0, + &_Internal_threads_System_initialization_thread->pending_events + ); + _Event_Surrender( _Internal_threads_System_initialization_thread ); + _Thread_Enable_dispatch(); } /*PAGE @@ -64,63 +70,88 @@ void rtems_multiprocessing_announce ( void ) * */ +typedef void (*packet_processor)( rtems_packet_prefix * ); + +packet_processor _Multiprocessor_Packet_processors[] = { + _Internal_threads_MP_Process_packet, /* RTEMS_MP_PACKET_INTERNAL_THREADS */ + _RTEMS_tasks_MP_Process_packet, /* RTEMS_MP_PACKET_TASKS */ + _Message_queue_MP_Process_packet, /* RTEMS_MP_PACKET_MESSAGE_QUEUE */ + _Semaphore_MP_Process_packet, /* RTEMS_MP_PACKET_SEMAPHORE */ + _Partition_MP_Process_packet, /* RTEMS_MP_PACKET_PARTITION */ + 0, /* RTEMS_MP_PACKET_REGION */ + _Event_MP_Process_packet, /* RTEMS_MP_PACKET_EVENT */ + _Signal_MP_Process_packet /* RTEMS_MP_PACKET_SIGNAL */ +}; + Thread _Multiprocessing_Receive_server ( Thread_Argument ignored ) { rtems_packet_prefix *the_packet; - - _Thread_Dispatch_disable_level = 1; + packet_processor the_function; for ( ; ; ) { - _Internal_threads_System_initialization_thread->Notepads[ 0 ] = 1; + _Thread_Disable_dispatch(); + _Event_Seize( RTEMS_EVENT_0, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); + _Thread_Enable_dispatch(); - the_packet = _MPCI_Receive_packet(); + for ( ; ; ) { + the_packet = _MPCI_Receive_packet(); - if ( ! the_packet ) { - _Thread_MP_Block(); - _Thread_Dispatch_disable_level = 1; - } - else { + if ( !the_packet ) + break; _Thread_Executing->receive_packet = the_packet; - switch ( the_packet->the_class ) { + if ( !_Mp_packet_Is_valid_packet_class ( the_packet->the_class ) ) + break; + + the_function = _Multiprocessor_Packet_processors[ the_packet->the_class ]; + + if ( !the_function ) + break; + (*the_function)( the_packet ); +#if 0 + switch ( the_packet->the_class ) { + case RTEMS_MP_PACKET_INTERNAL_THREADS: _Internal_threads_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_TASKS: _RTEMS_tasks_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_MESSAGE_QUEUE: _Message_queue_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_SEMAPHORE: _Semaphore_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_PARTITION: _Partition_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_REGION: /* Global regions are unsupported at this time */ break; - + case RTEMS_MP_PACKET_EVENT: _Event_MP_Process_packet( the_packet ); break; - + case RTEMS_MP_PACKET_SIGNAL: _Signal_MP_Process_packet( the_packet ); break; } +#endif + + } } } diff --git a/cpukit/score/include/rtems/score/mppkt.h b/cpukit/score/include/rtems/score/mppkt.h index e0cf6b1967..4e72d6930a 100644 --- a/cpukit/score/include/rtems/score/mppkt.h +++ b/cpukit/score/include/rtems/score/mppkt.h @@ -38,7 +38,7 @@ extern "C" { typedef enum { RTEMS_MP_PACKET_INTERNAL_THREADS = 0, - RTEMS_MP_PACKET_TASKS = 1, + RTEMS_MP_PACKET_TASKS = 1, RTEMS_MP_PACKET_MESSAGE_QUEUE = 2, RTEMS_MP_PACKET_SEMAPHORE = 3, RTEMS_MP_PACKET_PARTITION = 4, diff --git a/cpukit/score/include/rtems/score/threadmp.h b/cpukit/score/include/rtems/score/threadmp.h index c6e8252030..db94a65d78 100644 --- a/cpukit/score/include/rtems/score/threadmp.h +++ b/cpukit/score/include/rtems/score/threadmp.h @@ -89,26 +89,6 @@ Thread_Control *_Thread_MP_Find_proxy ( Objects_Id the_id ); -/* - * _Thread_MP_Block - * - * DESCRIPTION: - * - * This routine blocks the MP Receive server thread. - */ - -void _Thread_MP_Block( void ); - -/* - * _Thread_MP_Ready - * - * DESCRIPTION: - * - * This routine readies the MP Receive server thread. - */ - -void _Thread_MP_Ready( void ); - /* * The following is used to determine when the multiprocessing receive * thread is executing so that a proxy can be allocated instead of diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c index a181780e52..9c9a7691c8 100644 --- a/cpukit/score/src/thread.c +++ b/cpukit/score/src/thread.c @@ -316,7 +316,8 @@ void _Thread_Clear_state( if ( the_thread->current_priority < _Thread_Heir->current_priority ) { _Thread_Heir = the_thread; - if ( _Modes_Is_preempt( _Thread_Executing->current_modes ) ) + if ( _Modes_Is_preempt( _Thread_Executing->current_modes ) || + the_thread->current_priority == 0 ) _Context_Switch_necessary = TRUE; } } diff --git a/cpukit/score/src/threadmp.c b/cpukit/score/src/threadmp.c index 5d352e2d25..f2b78cd8cd 100644 --- a/cpukit/score/src/threadmp.c +++ b/cpukit/score/src/threadmp.c @@ -157,73 +157,3 @@ restart: _ISR_Enable( level ); return NULL; } - -/*PAGE - * - * _Thread_MP_Block - * - */ - -void _Thread_MP_Block( void ) -{ - ISR_Level level; - - _ISR_Disable( level ); - - if ( _Thread_MP_Receive->Notepads[ 0 ] != 0 ) { - _Priority_Remove_from_bit_map( &_Thread_MP_Receive->Priority_map ); - - _Thread_MP_Receive->current_state = STATES_SUSPENDED; - - _ISR_Flash( level ); - - _Thread_Calculate_heir(); - - _Context_Switch_necessary = TRUE; - - _ISR_Enable( level ); - - _Thread_Dispatch_disable_level = 0; - - _Thread_Dispatch(); - - return; - - } - _ISR_Enable( level ); - -} - -/*PAGE - * - * _Thread_MP_Ready - * - */ - -void _Thread_MP_Ready( void ) -{ - ISR_Level level; - - _ISR_Disable( level ); - - if ( _States_Is_suspended( _Thread_MP_Receive->current_state ) ) { - _Priority_Add_to_bit_map( &_Thread_MP_Receive->Priority_map ); - - _Thread_MP_Receive->current_state = STATES_READY; - - _Thread_Heir = _Thread_MP_Receive; - - _Context_Switch_necessary = TRUE; - - _ISR_Enable( level ); - - if ( _Thread_Is_dispatching_enabled() ) - _Thread_Dispatch(); - - } else { - - _Thread_MP_Receive->Notepads[ 0 ] = 0; - _ISR_Enable( level ); - - } -} -- cgit v1.2.3