summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-19 17:02:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:08 +0200
commit4025a60fcb892169266102a58beef4caad17340c (patch)
tree004df492a31db98faa24335a663eed429ebb5d05
parentposix: Avoid Giant lock in sem_getvalue() (diff)
downloadrtems-4025a60fcb892169266102a58beef4caad17340c.tar.bz2
score: Avoid Giant lock for CORE mtx/sem
Avoid Giant lock for CORE mutex and semaphore flush and delete operations. Update #2555.
-rw-r--r--cpukit/posix/include/rtems/posix/semaphoreimpl.h26
-rw-r--r--cpukit/posix/src/semaphoredeletesupp.c22
-rw-r--r--cpukit/posix/src/semclose.c22
-rw-r--r--cpukit/posix/src/semdestroy.c27
-rw-r--r--cpukit/posix/src/semunlink.c9
-rw-r--r--cpukit/rtems/src/semdelete.c83
-rw-r--r--cpukit/rtems/src/semflush.c25
-rw-r--r--cpukit/score/include/rtems/score/coremuteximpl.h26
-rw-r--r--cpukit/score/include/rtems/score/coresemimpl.h46
-rw-r--r--cpukit/score/include/rtems/score/mrspimpl.h41
10 files changed, 186 insertions, 141 deletions
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index 41bfdad65a..d726761689 100644
--- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
+++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
@@ -22,8 +22,7 @@
#include <rtems/posix/semaphore.h>
#include <rtems/posix/posixapi.h>
#include <rtems/score/coresemimpl.h>
-
-#include <errno.h>
+#include <rtems/seterr.h>
#ifdef __cplusplus
extern "C" {
@@ -61,26 +60,6 @@ RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free (
_Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
}
-/**
- * @brief POSIX Semaphore Get
- *
- * 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 POSIX_Semaphore_Control *_POSIX_Semaphore_Get (
- sem_t *id,
- Objects_Locations *location
-)
-{
- return (POSIX_Semaphore_Control *)
- _Objects_Get( &_POSIX_Semaphore_Information, (Objects_Id)*id, location );
-}
-
RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *
_POSIX_Semaphore_Get_interrupt_disable(
sem_t *id,
@@ -116,7 +95,8 @@ int _POSIX_Semaphore_Create_support(
* This routine supports the sem_close and sem_unlink routines.
*/
void _POSIX_Semaphore_Delete(
- POSIX_Semaphore_Control *the_semaphore
+ POSIX_Semaphore_Control *the_semaphore,
+ ISR_lock_Context *lock_context
);
/**
diff --git a/cpukit/posix/src/semaphoredeletesupp.c b/cpukit/posix/src/semaphoredeletesupp.c
index 4394674699..7c23bb889d 100644
--- a/cpukit/posix/src/semaphoredeletesupp.c
+++ b/cpukit/posix/src/semaphoredeletesupp.c
@@ -18,25 +18,23 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <limits.h>
-
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
void _POSIX_Semaphore_Delete(
- POSIX_Semaphore_Control *the_semaphore
+ POSIX_Semaphore_Control *the_semaphore,
+ ISR_lock_Context *lock_context
)
{
if ( !the_semaphore->linked && !the_semaphore->open_count ) {
_Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
- _CORE_semaphore_Destroy( &the_semaphore->Semaphore, NULL, 0 );
+ _CORE_semaphore_Destroy(
+ &the_semaphore->Semaphore,
+ NULL,
+ 0,
+ lock_context
+ );
_POSIX_Semaphore_Free( the_semaphore );
+ } else {
+ _CORE_semaphore_Release( &the_semaphore->Semaphore, lock_context );
}
}
diff --git a/cpukit/posix/src/semclose.c b/cpukit/posix/src/semclose.c
index f134dc43a7..1468c7fb35 100644
--- a/cpukit/posix/src/semclose.c
+++ b/cpukit/posix/src/semclose.c
@@ -18,17 +18,9 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_close(
sem_t *sem
@@ -36,15 +28,23 @@ int sem_close(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
- the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+ the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+ sem,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
+ _CORE_semaphore_Acquire_critical(
+ &the_semaphore->Semaphore,
+ &lock_context
+ );
the_semaphore->open_count -= 1;
- _POSIX_Semaphore_Delete( the_semaphore );
- _Objects_Put( &the_semaphore->Object );
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;
diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c
index 896dece149..751169941b 100644
--- a/cpukit/posix/src/semdestroy.c
+++ b/cpukit/posix/src/semdestroy.c
@@ -18,17 +18,9 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
#include <semaphore.h>
-#include <limits.h>
-#include <rtems/system.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_destroy(
sem_t *sem
@@ -36,21 +28,30 @@ int sem_destroy(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
- the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+ the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+ sem,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
+ _CORE_semaphore_Acquire_critical(
+ &the_semaphore->Semaphore,
+ &lock_context
+ );
+
/*
* Undefined operation on a named semaphore. Release the object
* and fall to the EINVAL return at the bottom.
*/
- if ( the_semaphore->named == true ) {
- _Objects_Put( &the_semaphore->Object );
+ if ( the_semaphore->named ) {
+ _CORE_semaphore_Release( &the_semaphore->Semaphore, &lock_context );
} else {
- _POSIX_Semaphore_Delete( the_semaphore );
- _Objects_Put( &the_semaphore->Object );
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;
}
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index b8406185d4..665aa7337c 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -21,7 +21,6 @@
#include <semaphore.h>
#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
int sem_unlink(
const char *name
@@ -29,6 +28,7 @@ int sem_unlink(
{
POSIX_Semaphore_Control *the_semaphore;
Objects_Get_by_name_error error;
+ ISR_lock_Context lock_context;
_Objects_Allocator_lock();
@@ -38,9 +38,12 @@ int sem_unlink(
rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
}
- the_semaphore->linked = false;
_POSIX_Semaphore_Namespace_remove( the_semaphore );
- _POSIX_Semaphore_Delete( the_semaphore );
+
+ _ISR_lock_ISR_disable( &lock_context );
+ _CORE_semaphore_Acquire_critical( &the_semaphore->Semaphore, &lock_context );
+ the_semaphore->linked = false;
+ _POSIX_Semaphore_Delete( the_semaphore, &lock_context );
_Objects_Allocator_unlock();
return 0;
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 48a9055cbb..eebe88afa8 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -37,11 +37,16 @@ rtems_status_code rtems_semaphore_delete(
{
Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
rtems_attribute attribute_set;
_Objects_Allocator_lock();
- the_semaphore = _Semaphore_Get( id, &location );
+ the_semaphore = _Semaphore_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -50,43 +55,50 @@ rtems_status_code rtems_semaphore_delete(
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 ) {
- _Objects_Put( &the_semaphore->Object );
+ _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_Is_locked( &the_semaphore->Core_control.mutex )
- && !_Attributes_Is_simple_binary_semaphore( attribute_set )
- ) {
- _Objects_Put( &the_semaphore->Object );
- _Objects_Allocator_unlock();
- return RTEMS_RESOURCE_IN_USE;
- }
-
- _Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
-
-#if defined(RTEMS_MULTIPROCESSING)
- if ( _Attributes_Is_global( attribute_set ) ) {
-
- _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id );
+ if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
+ _CORE_mutex_Acquire_critical(
+ &the_semaphore->Core_control.mutex,
+ &lock_context
+ );
- _Semaphore_MP_Send_process_packet(
- SEMAPHORE_MP_ANNOUNCE_DELETE,
- the_semaphore->Object.id,
- 0, /* Not used */
- 0 /* Not used */
+ 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
);
}
-#endif
+
+ _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 );
+ _MRSP_Destroy( &the_semaphore->Core_control.mrsp, &lock_context );
} else
#endif
if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
@@ -94,18 +106,33 @@ rtems_status_code rtems_semaphore_delete(
&the_semaphore->Core_control.mutex,
_CORE_mutex_Was_deleted,
_Semaphore_MP_Send_object_was_deleted,
- id
+ 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
+ id,
+ &lock_context
);
}
- _Objects_Put( &the_semaphore->Object );
+#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;
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c
index 01c5c0ddcd..13dcf22785 100644
--- a/cpukit/rtems/src/semflush.c
+++ b/cpukit/rtems/src/semflush.c
@@ -37,39 +37,52 @@ rtems_status_code rtems_semaphore_flush(
{
Semaphore_Control *the_semaphore;
Objects_Locations location;
+ ISR_lock_Context lock_context;
rtems_attribute attribute_set;
- the_semaphore = _Semaphore_Get( id, &location );
+ 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 ) ) {
- _Objects_Put( &the_semaphore->Object );
+ _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
+ 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
+ id,
+ &lock_context
);
}
- _Objects_Put( &the_semaphore->Object );
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
- _Thread_Dispatch();
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
#endif
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index 73331a5f32..49404ce6c0 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -355,23 +355,17 @@ Thread_Control *_CORE_mutex_Unsatisfied_nowait(
the_mutex, \
filter, \
mp_callout, \
- mp_id \
+ mp_id, \
+ lock_context \
) \
- do { \
- ISR_lock_Context _core_mutex_flush_lock_context; \
- _Thread_queue_Acquire( \
- &( the_mutex )->Wait_queue, \
- &_core_mutex_flush_lock_context \
- ); \
- _Thread_queue_Flush_critical( \
- &( the_mutex )->Wait_queue.Queue, \
- ( the_mutex )->operations, \
- filter, \
- mp_callout, \
- mp_id, \
- &_core_mutex_flush_lock_context \
- ); \
- } while ( 0 )
+ _Thread_queue_Flush_critical( \
+ &( the_mutex )->Wait_queue.Queue, \
+ ( the_mutex )->operations, \
+ filter, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ )
/**
* @brief Is mutex locked.
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index fd01f93150..bc174066ab 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -86,6 +86,22 @@ void _CORE_semaphore_Initialize(
uint32_t initial_value
);
+RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical(
+ CORE_semaphore_Control *the_semaphore,
+ ISR_lock_Context *lock_context
+)
+{
+ _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, lock_context );
+}
+
+RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release(
+ CORE_semaphore_Control *the_semaphore,
+ ISR_lock_Context *lock_context
+)
+{
+ _Thread_queue_Release( &the_semaphore->Wait_queue, lock_context );
+}
+
Thread_Control *_CORE_semaphore_Was_deleted(
Thread_Control *the_thread,
Thread_queue_Queue *queue,
@@ -101,21 +117,17 @@ Thread_Control *_CORE_semaphore_Unsatisfied_nowait(
#define _CORE_semaphore_Destroy( \
the_semaphore, \
mp_callout, \
- mp_id \
+ mp_id, \
+ lock_context \
) \
do { \
- ISR_lock_Context _core_semaphore_destroy_lock_context; \
- _Thread_queue_Acquire( \
- &( the_semaphore )->Wait_queue, \
- &_core_semaphore_destroy_lock_context \
- ); \
_Thread_queue_Flush_critical( \
&( the_semaphore )->Wait_queue.Queue, \
( the_semaphore )->operations, \
_CORE_semaphore_Was_deleted, \
mp_callout, \
mp_id, \
- &_core_semaphore_destroy_lock_context \
+ lock_context \
); \
_Thread_queue_Destroy( &( the_semaphore )->Wait_queue ); \
} while ( 0 )
@@ -134,7 +146,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Do_surrender(
status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
- _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, lock_context );
+ _CORE_semaphore_Acquire_critical( the_semaphore, lock_context );
the_thread = _Thread_queue_First_locked(
&the_semaphore->Wait_queue,
@@ -155,7 +167,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Do_surrender(
else
status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
- _Thread_queue_Release( &the_semaphore->Wait_queue, lock_context );
+ _CORE_semaphore_Release( the_semaphore, lock_context );
}
return status;
@@ -208,21 +220,17 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Do_surrender(
#define _CORE_semaphore_Flush( \
the_semaphore, \
mp_callout, \
- mp_id \
+ mp_id, \
+ lock_context \
) \
do { \
- ISR_lock_Context _core_semaphore_flush_lock_context; \
- _Thread_queue_Acquire( \
- &( the_semaphore )->Wait_queue, \
- &_core_semaphore_flush_lock_context \
- ); \
_Thread_queue_Flush_critical( \
&( the_semaphore )->Wait_queue.Queue, \
( the_semaphore )->operations, \
_CORE_semaphore_Unsatisfied_nowait, \
mp_callout, \
mp_id, \
- &_core_semaphore_flush_lock_context \
+ lock_context \
); \
} while ( 0 )
@@ -268,15 +276,15 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
/* disabled when you get here */
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
- _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, lock_context );
+ _CORE_semaphore_Acquire_critical( the_semaphore, lock_context );
if ( the_semaphore->count != 0 ) {
the_semaphore->count -= 1;
- _Thread_queue_Release( &the_semaphore->Wait_queue, lock_context );
+ _CORE_semaphore_Release( the_semaphore, lock_context );
return;
}
if ( !wait ) {
- _Thread_queue_Release( &the_semaphore->Wait_queue, lock_context );
+ _CORE_semaphore_Release( the_semaphore, lock_context );
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
return;
}
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 1529b1a461..1be320236a 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -53,6 +53,22 @@ RTEMS_INLINE_ROUTINE void _MRSP_Giant_release( ISR_lock_Context *lock_context )
_ISR_lock_Release( &_Scheduler_Lock, lock_context );
}
+RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical(
+ MRSP_Control *mrsp,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Acquire( &mrsp->Lock, lock_context );
+}
+
+RTEMS_INLINE_ROUTINE void _MRSP_Release(
+ MRSP_Control *mrsp,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, lock_context );
+}
+
RTEMS_INLINE_ROUTINE bool _MRSP_Restore_priority_filter(
Thread_Control *thread,
Priority_Control *new_priority,
@@ -103,7 +119,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Claim_ownership(
_Scheduler_Thread_change_help_state( new_owner, SCHEDULER_HELP_ACTIVE_OWNER );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, lock_context );
+ _MRSP_Release( mrsp, lock_context );
_Thread_Raise_priority( new_owner, ceiling_priority );
@@ -166,7 +182,8 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
Thread_Control *thread = rival->thread;
ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &mrsp->Lock, &lock_context );
+ _ISR_lock_ISR_disable( &lock_context );
+ _MRSP_Acquire_critical( mrsp, &lock_context );
if ( rival->status == MRSP_WAIT_FOR_OWNERSHIP ) {
ISR_lock_Context giant_lock_context;
@@ -183,9 +200,9 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
rival->status = MRSP_TIMEOUT;
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, &lock_context );
+ _MRSP_Release( mrsp, &lock_context );
} else {
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, &lock_context );
+ _MRSP_Release( mrsp, &lock_context );
}
}
@@ -227,7 +244,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
_MRSP_Giant_release( &giant_lock_context );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, lock_context );
+ _MRSP_Release( mrsp, lock_context );
_Thread_Raise_priority( executing, ceiling_priority );
@@ -293,7 +310,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
return MRSP_INVALID_PRIORITY;
}
- _ISR_lock_Acquire( &mrsp->Lock, lock_context );
+ _MRSP_Acquire_critical( mrsp, lock_context );
owner = _Resource_Get_owner( &mrsp->Resource );
if ( owner == NULL ) {
_MRSP_Claim_ownership(
@@ -318,7 +335,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Seize(
lock_context
);
} else {
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, lock_context );
+ _MRSP_Release( mrsp, lock_context );
/* Not available, nested access or deadlock */
status = MRSP_UNSATISFIED;
}
@@ -353,7 +370,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
initial_priority = mrsp->initial_priority_of_owner;
- _ISR_lock_Acquire( &mrsp->Lock, lock_context );
+ _MRSP_Acquire_critical( mrsp, lock_context );
_MRSP_Giant_acquire( &giant_lock_context );
@@ -389,7 +406,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Surrender(
_MRSP_Giant_release( &giant_lock_context );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, lock_context );
+ _MRSP_Release( mrsp, lock_context );
_MRSP_Restore_priority( executing, initial_priority );
@@ -407,8 +424,12 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Can_destroy( MRSP_Control *mrsp )
return MRSP_SUCCESSFUL;
}
-RTEMS_INLINE_ROUTINE void _MRSP_Destroy( MRSP_Control *mrsp )
+RTEMS_INLINE_ROUTINE void _MRSP_Destroy(
+ MRSP_Control *mrsp,
+ ISR_lock_Context *lock_context
+)
{
+ _MRSP_Release( mrsp, lock_context );
_ISR_lock_Destroy( &mrsp->Lock );
_Workspace_Free( mrsp->ceiling_priorities );
}