mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 19:26:11 +08:00
rtems: _Semaphore_Get_interrupt_disable()
Use _Objects_Get_local() for _Semaphore_Get_interrupt_disable() to get rid of the location parameter. Move remote object handling to semaphore MPCI support.
This commit is contained in:
@@ -134,28 +134,15 @@ RTEMS_INLINE_ROUTINE void _Semaphore_Free (
|
||||
_Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Maps semaphore IDs to semaphore control blocks.
|
||||
*
|
||||
* This function maps semaphore IDs to semaphore control blocks.
|
||||
* If ID corresponds to a local semaphore, then it returns
|
||||
* the_semaphore control pointer which maps to ID and location
|
||||
* is set to OBJECTS_LOCAL. if the semaphore ID is global and
|
||||
* resides on a remote node, then location is set to OBJECTS_REMOTE,
|
||||
* and the_semaphore is undefined. Otherwise, location is set
|
||||
* to OBJECTS_ERROR and the_semaphore is undefined.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get_interrupt_disable (
|
||||
RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get_interrupt_disable(
|
||||
Objects_Id id,
|
||||
Objects_Locations *location,
|
||||
ISR_lock_Context *lock_context
|
||||
)
|
||||
{
|
||||
return (Semaphore_Control *) _Objects_Get_isr_disable(
|
||||
&_Semaphore_Information,
|
||||
return (Semaphore_Control *) _Objects_Get_local(
|
||||
id,
|
||||
location,
|
||||
lock_context
|
||||
lock_context,
|
||||
&_Semaphore_Information
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,11 @@ typedef struct {
|
||||
Objects_Id proxy_id;
|
||||
} Semaphore_MP_Packet;
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Semaphore_MP_Is_remote( Objects_Id id )
|
||||
{
|
||||
return _Objects_MP_Is_remote( id, &_Semaphore_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Semaphore MP Send Process Packet
|
||||
*
|
||||
@@ -79,18 +84,19 @@ void _Semaphore_MP_Send_process_packet (
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Semaphore MP Send Request Packet
|
||||
*
|
||||
* This routine performs a remote procedure call so that a
|
||||
* directive operation can be initiated on another node.
|
||||
* @brief Issues a remote rtems_semaphore_obtain() request.
|
||||
*/
|
||||
rtems_status_code _Semaphore_MP_Send_request_packet (
|
||||
Semaphore_MP_Remote_operations operation,
|
||||
Objects_Id semaphore_id,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
rtems_status_code _Semaphore_MP_Obtain(
|
||||
rtems_id id,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_semaphore_release() request.
|
||||
*/
|
||||
rtems_status_code _Semaphore_MP_Release( rtems_id id );
|
||||
|
||||
/**
|
||||
* @brief Semaphore MP Process Packet
|
||||
*
|
||||
|
||||
+96
-114
@@ -18,135 +18,117 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/semimpl.h>
|
||||
#include <rtems/score/coremuteximpl.h>
|
||||
#include <rtems/score/coresemimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
|
||||
#include <rtems/score/interr.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
|
||||
rtems_status_code rtems_semaphore_delete(
|
||||
rtems_id id
|
||||
)
|
||||
{
|
||||
Semaphore_Control *the_semaphore;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
rtems_attribute attribute_set;
|
||||
Semaphore_Control *the_semaphore;
|
||||
ISR_lock_Context lock_context;
|
||||
rtems_attribute attribute_set;
|
||||
|
||||
_Objects_Allocator_lock();
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context );
|
||||
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
_MRSP_Acquire_critical(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
&lock_context
|
||||
);
|
||||
mrsp_status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
|
||||
if ( mrsp_status != MRSP_SUCCESSFUL ) {
|
||||
_MRSP_Release(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
&lock_context
|
||||
);
|
||||
_Objects_Allocator_unlock();
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Acquire_critical(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
if (
|
||||
_CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
|
||||
&& !_Attributes_Is_simple_binary_semaphore( attribute_set )
|
||||
) {
|
||||
_CORE_mutex_Release(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_RESOURCE_IN_USE;
|
||||
}
|
||||
} else {
|
||||
_CORE_semaphore_Acquire_critical(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
|
||||
_Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
_MRSP_Destroy( &the_semaphore->Core_control.mrsp, &lock_context );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Flush(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_CORE_mutex_Was_deleted,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
|
||||
} else {
|
||||
_CORE_semaphore_Destroy(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
if ( the_semaphore == NULL ) {
|
||||
_Objects_Allocator_unlock();
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
if ( _Attributes_Is_global( attribute_set ) ) {
|
||||
|
||||
_Objects_MP_Close( &_Semaphore_Information, id );
|
||||
|
||||
_Semaphore_MP_Send_process_packet(
|
||||
SEMAPHORE_MP_ANNOUNCE_DELETE,
|
||||
id,
|
||||
0, /* Not used */
|
||||
0 /* Not used */
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
_Semaphore_Free( the_semaphore );
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
_Objects_Allocator_unlock();
|
||||
if ( _Semaphore_MP_Is_remote( id ) ) {
|
||||
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
_MRSP_Acquire_critical(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
&lock_context
|
||||
);
|
||||
mrsp_status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
|
||||
if ( mrsp_status != MRSP_SUCCESSFUL ) {
|
||||
_MRSP_Release(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
&lock_context
|
||||
);
|
||||
_Objects_Allocator_unlock();
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Acquire_critical(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
if (
|
||||
_CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
|
||||
&& !_Attributes_Is_simple_binary_semaphore( attribute_set )
|
||||
) {
|
||||
_CORE_mutex_Release(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_RESOURCE_IN_USE;
|
||||
}
|
||||
} else {
|
||||
_CORE_semaphore_Acquire_critical(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
|
||||
_Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
_MRSP_Destroy( &the_semaphore->Core_control.mrsp, &lock_context );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Flush(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_CORE_mutex_Was_deleted,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
|
||||
} else {
|
||||
_CORE_semaphore_Destroy(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
if ( _Attributes_Is_global( attribute_set ) ) {
|
||||
|
||||
_Objects_MP_Close( &_Semaphore_Information, id );
|
||||
|
||||
_Semaphore_MP_Send_process_packet(
|
||||
SEMAPHORE_MP_ANNOUNCE_DELETE,
|
||||
id,
|
||||
0, /* Not used */
|
||||
0 /* Not used */
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
_Semaphore_Free( the_semaphore );
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_INVALID_ID;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
+43
-62
@@ -18,77 +18,58 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/semimpl.h>
|
||||
#include <rtems/score/coremuteximpl.h>
|
||||
#include <rtems/score/coresemimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
|
||||
#include <rtems/score/interr.h>
|
||||
|
||||
rtems_status_code rtems_semaphore_flush(
|
||||
rtems_id id
|
||||
)
|
||||
rtems_status_code rtems_semaphore_flush( rtems_id id )
|
||||
{
|
||||
Semaphore_Control *the_semaphore;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
rtems_attribute attribute_set;
|
||||
Semaphore_Control *the_semaphore;
|
||||
ISR_lock_Context lock_context;
|
||||
rtems_attribute attribute_set;
|
||||
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
_ISR_lock_ISR_enable( &lock_context );
|
||||
return RTEMS_NOT_DEFINED;
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Acquire_critical(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_mutex_Flush(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_CORE_mutex_Unsatisfied_nowait,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
} else {
|
||||
_CORE_semaphore_Acquire_critical(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_semaphore_Flush(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context );
|
||||
|
||||
if ( the_semaphore == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
if ( _Semaphore_MP_Is_remote( id ) ) {
|
||||
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
_ISR_lock_ISR_enable( &lock_context );
|
||||
return RTEMS_NOT_DEFINED;
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Acquire_critical(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_mutex_Flush(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_CORE_mutex_Unsatisfied_nowait,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
} else {
|
||||
_CORE_semaphore_Acquire_critical(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
&lock_context
|
||||
);
|
||||
_CORE_semaphore_Flush(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ void _Semaphore_MP_Send_process_packet (
|
||||
}
|
||||
}
|
||||
|
||||
rtems_status_code _Semaphore_MP_Send_request_packet (
|
||||
Semaphore_MP_Remote_operations operation,
|
||||
static rtems_status_code _Semaphore_MP_Send_request_packet(
|
||||
Objects_Id semaphore_id,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
rtems_interval timeout,
|
||||
Semaphore_MP_Remote_operations operation
|
||||
)
|
||||
{
|
||||
Semaphore_MP_Packet *the_packet;
|
||||
@@ -120,6 +120,30 @@ rtems_status_code _Semaphore_MP_Send_request_packet (
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_status_code _Semaphore_MP_Obtain(
|
||||
rtems_id id,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
)
|
||||
{
|
||||
return _Semaphore_MP_Send_request_packet(
|
||||
id,
|
||||
option_set,
|
||||
timeout,
|
||||
SEMAPHORE_MP_OBTAIN_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Semaphore_MP_Release( rtems_id id )
|
||||
{
|
||||
return _Semaphore_MP_Send_request_packet(
|
||||
id,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
SEMAPHORE_MP_RELEASE_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
static void _Semaphore_MP_Send_response_packet (
|
||||
Semaphore_MP_Remote_operations operation,
|
||||
Objects_Id semaphore_id,
|
||||
|
||||
@@ -18,18 +18,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/rtems/optionsimpl.h>
|
||||
#include <rtems/rtems/semimpl.h>
|
||||
#include <rtems/score/coremuteximpl.h>
|
||||
#include <rtems/score/coresemimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
|
||||
#include <rtems/score/interr.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/optionsimpl.h>
|
||||
|
||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
||||
Semaphore_Control,
|
||||
@@ -47,76 +39,62 @@ rtems_status_code rtems_semaphore_obtain(
|
||||
rtems_interval timeout
|
||||
)
|
||||
{
|
||||
Semaphore_Control *the_semaphore;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Thread_Control *executing;
|
||||
rtems_attribute attribute_set;
|
||||
bool wait;
|
||||
Semaphore_Control *the_semaphore;
|
||||
ISR_lock_Context lock_context;
|
||||
Thread_Control *executing;
|
||||
rtems_attribute attribute_set;
|
||||
bool wait;
|
||||
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
executing = _Thread_Executing;
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
wait = !_Options_Is_no_wait( option_set );
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
mrsp_status = _MRSP_Seize(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
executing,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Seize(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
executing,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_mutex_return_code(
|
||||
executing->Wait.return_code );
|
||||
}
|
||||
|
||||
/* must be a counting semaphore */
|
||||
_CORE_semaphore_Seize(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
executing,
|
||||
id,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_semaphore_return_code(
|
||||
executing->Wait.return_code );
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context );
|
||||
|
||||
if ( the_semaphore == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
return _Semaphore_MP_Send_request_packet(
|
||||
SEMAPHORE_MP_OBTAIN_REQUEST,
|
||||
id,
|
||||
option_set,
|
||||
timeout
|
||||
);
|
||||
_Semaphore_MP_Obtain( id, option_set, timeout );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
executing = _Thread_Executing;
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
wait = !_Options_Is_no_wait( option_set );
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
mrsp_status = _MRSP_Seize(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
executing,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
_CORE_mutex_Seize(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
executing,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_mutex_return_code(
|
||||
executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
/* must be a counting semaphore */
|
||||
_CORE_semaphore_Seize(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
executing,
|
||||
id,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_semaphore_return_code(
|
||||
executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,82 +21,55 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/semimpl.h>
|
||||
#include <rtems/score/coremuteximpl.h>
|
||||
#include <rtems/score/coresemimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/interr.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
|
||||
rtems_status_code rtems_semaphore_release(
|
||||
rtems_id id
|
||||
)
|
||||
rtems_status_code rtems_semaphore_release( rtems_id id )
|
||||
{
|
||||
Semaphore_Control *the_semaphore;
|
||||
Objects_Locations location;
|
||||
CORE_mutex_Status mutex_status;
|
||||
CORE_semaphore_Status semaphore_status;
|
||||
rtems_attribute attribute_set;
|
||||
ISR_lock_Context lock_context;
|
||||
Semaphore_Control *the_semaphore;
|
||||
CORE_mutex_Status mutex_status;
|
||||
CORE_semaphore_Status semaphore_status;
|
||||
rtems_attribute attribute_set;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
mrsp_status = _MRSP_Surrender(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
_Thread_Executing,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
mutex_status = _CORE_mutex_Surrender(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_Semaphore_Core_mutex_mp_support,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_mutex_return_code( mutex_status );
|
||||
} else {
|
||||
semaphore_status = _CORE_semaphore_Surrender(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_Core_mutex_mp_support,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
return
|
||||
_Semaphore_Translate_core_semaphore_return_code( semaphore_status );
|
||||
}
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context );
|
||||
|
||||
if ( the_semaphore == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
return _Semaphore_MP_Send_request_packet(
|
||||
SEMAPHORE_MP_RELEASE_REQUEST,
|
||||
id,
|
||||
0, /* Not used */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
_Semaphore_MP_Release( id );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
attribute_set = the_semaphore->attribute_set;
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
|
||||
MRSP_Status mrsp_status;
|
||||
|
||||
mrsp_status = _MRSP_Surrender(
|
||||
&the_semaphore->Core_control.mrsp,
|
||||
_Thread_Executing,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_MRSP_status_code( mrsp_status );
|
||||
} else
|
||||
#endif
|
||||
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
|
||||
mutex_status = _CORE_mutex_Surrender(
|
||||
&the_semaphore->Core_control.mutex,
|
||||
_Semaphore_Core_mutex_mp_support,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_mutex_return_code( mutex_status );
|
||||
} else {
|
||||
semaphore_status = _CORE_semaphore_Surrender(
|
||||
&the_semaphore->Core_control.semaphore,
|
||||
_Semaphore_Core_mutex_mp_support,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
return _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ rtems_status_code rtems_semaphore_set_priority(
|
||||
)
|
||||
{
|
||||
Semaphore_Control *the_semaphore;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
if ( new_priority != RTEMS_CURRENT_PRIORITY &&
|
||||
@@ -106,25 +105,24 @@ rtems_status_code rtems_semaphore_set_priority(
|
||||
|
||||
the_semaphore = _Semaphore_Get_interrupt_disable(
|
||||
semaphore_id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
case OBJECTS_LOCAL:
|
||||
return _Semaphore_Set_priority(
|
||||
the_semaphore,
|
||||
scheduler_id,
|
||||
new_priority,
|
||||
old_priority,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
if ( the_semaphore == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
if ( _Semaphore_MP_Is_remote( semaphore_id ) ) {
|
||||
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
|
||||
}
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
return _Semaphore_Set_priority(
|
||||
the_semaphore,
|
||||
scheduler_id,
|
||||
new_priority,
|
||||
old_priority,
|
||||
&lock_context
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,11 +33,10 @@ static test_context ctx_instance;
|
||||
|
||||
static Semaphore_Control *get_semaphore_control(rtems_id id)
|
||||
{
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Semaphore_Control *sem;
|
||||
|
||||
sem = _Semaphore_Get_interrupt_disable(id, &location, &lock_context);
|
||||
sem = _Semaphore_Get_interrupt_disable(id, &lock_context);
|
||||
rtems_test_assert(sem != NULL);
|
||||
_ISR_lock_ISR_enable(&lock_context);
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ const char rtems_test_name[] = "TIME TEST 26";
|
||||
/* TEST DATA */
|
||||
rtems_id Semaphore_id;
|
||||
|
||||
Objects_Locations location; /* uses internal RTEMS type */
|
||||
|
||||
Thread_Control *Middle_tcb; /* uses internal RTEMS type */
|
||||
|
||||
Thread_Control *Low_tcb; /* uses internal RTEMS type */
|
||||
@@ -517,7 +515,6 @@ void complete_test( void )
|
||||
for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
|
||||
(void) _Semaphore_Get_interrupt_disable(
|
||||
Semaphore_id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
_ISR_lock_ISR_enable( &lock_context );
|
||||
|
||||
Reference in New Issue
Block a user