From bb2ad039a7246eecde65592a5116c86d3dede34b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 4 May 2016 10:09:45 +0200 Subject: rtems: Avoid Giant lock for signals Update #2555. --- cpukit/rtems/src/signalmp.c | 79 ++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 34 deletions(-) (limited to 'cpukit/rtems/src/signalmp.c') diff --git a/cpukit/rtems/src/signalmp.c b/cpukit/rtems/src/signalmp.c index 8c63c2f790..cd89e9f0dd 100644 --- a/cpukit/rtems/src/signalmp.c +++ b/cpukit/rtems/src/signalmp.c @@ -24,13 +24,36 @@ #include #include +/** + * The following enumerated type defines the list of + * remote signal operations. + */ +typedef enum { + SIGNAL_MP_SEND_REQUEST = 0, + SIGNAL_MP_SEND_RESPONSE = 1 +} Signal_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote signal operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Signal_MP_Remote_operations operation; + rtems_signal_set signal_set; +} Signal_MP_Packet; + RTEMS_STATIC_ASSERT( sizeof(Signal_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE, Signal_MP_Packet ); -static Signal_MP_Packet *_Signal_MP_Get_packet( void ) +static Signal_MP_Packet *_Signal_MP_Get_packet( Objects_Id id ) { + if ( !_Thread_MP_Is_remote( id ) ) { + return NULL; + } + return (Signal_MP_Packet *) _MPCI_Get_packet(); } @@ -42,43 +65,31 @@ static Signal_MP_Packet *_Signal_MP_Get_packet( void ) * */ -rtems_status_code _Signal_MP_Send_request_packet ( - Signal_MP_Remote_operations operation, - Objects_Id task_id, - rtems_signal_set signal_in +rtems_status_code _Signal_MP_Send( + rtems_id id, + rtems_signal_set signal_set ) { Signal_MP_Packet *the_packet; - switch ( operation ) { - - case SIGNAL_MP_SEND_REQUEST: - - the_packet = _Signal_MP_Get_packet(); - the_packet->Prefix.the_class = MP_PACKET_SIGNAL; - the_packet->Prefix.length = sizeof ( Signal_MP_Packet ); - the_packet->Prefix.to_convert = sizeof ( Signal_MP_Packet ); - the_packet->operation = operation; - the_packet->Prefix.id = task_id; - the_packet->signal_in = signal_in; - - return _MPCI_Send_request_packet( - _Objects_Get_node( task_id ), - &the_packet->Prefix, - STATES_READY, /* Not used */ - RTEMS_TIMEOUT - ); - break; - - case SIGNAL_MP_SEND_RESPONSE: - break; - + the_packet = _Signal_MP_Get_packet( id ); + if ( the_packet == NULL ) { + return RTEMS_INVALID_ID; } - /* - * The following line is included to satisfy compilers which - * produce warnings when a function does not end with a return. - */ - return RTEMS_INTERNAL_ERROR; + + the_packet->Prefix.the_class = MP_PACKET_SIGNAL; + the_packet->Prefix.length = sizeof( *the_packet ); + the_packet->Prefix.to_convert = sizeof( *the_packet ); + the_packet->operation = SIGNAL_MP_SEND_REQUEST; + the_packet->Prefix.id = id; + the_packet->signal_set = signal_set; + + return (rtems_status_code) _MPCI_Send_request_packet( + _Objects_Get_node( id ), + &the_packet->Prefix, + STATES_READY, + RTEMS_TIMEOUT + ); } static void _Signal_MP_Send_response_packet ( @@ -127,7 +138,7 @@ void _Signal_MP_Process_packet ( the_packet->Prefix.return_code = rtems_signal_send( the_packet->Prefix.id, - the_packet->signal_in + the_packet->signal_set ); _Signal_MP_Send_response_packet( -- cgit v1.2.3