From 02c4c441a51b43b55608893efa4a80a62bb9d4d5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 23 Apr 2015 10:01:22 +0200 Subject: score: Add Thread_queue_Control::Lock Move the complete thread queue enqueue procedure into _Thread_queue_Enqueue_critical(). It is possible to use the thread queue lock to protect state of the object embedding the thread queue. This enables per object fine grained locking in the future. Delete _Thread_queue_Enter_critical_section(). Update #2273. --- cpukit/rtems/include/rtems/rtems/barrierimpl.h | 1 + cpukit/rtems/include/rtems/rtems/messageimpl.h | 1 + cpukit/rtems/include/rtems/rtems/regionimpl.h | 2 ++ cpukit/rtems/src/regioncreate.c | 18 +++++++----------- cpukit/rtems/src/regiongetsegment.c | 3 --- cpukit/rtems/src/semdelete.c | 2 ++ 6 files changed, 13 insertions(+), 14 deletions(-) (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/include/rtems/rtems/barrierimpl.h b/cpukit/rtems/include/rtems/rtems/barrierimpl.h index 963ebd93da..e718028715 100644 --- a/cpukit/rtems/include/rtems/rtems/barrierimpl.h +++ b/cpukit/rtems/include/rtems/rtems/barrierimpl.h @@ -86,6 +86,7 @@ RTEMS_INLINE_ROUTINE void _Barrier_Free ( Barrier_Control *the_barrier ) { + _CORE_barrier_Destroy( &the_barrier->Barrier ); _Objects_Free( &_Barrier_Information, &the_barrier->Object ); } diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h index e2bc88d0db..fa9e573892 100644 --- a/cpukit/rtems/include/rtems/rtems/messageimpl.h +++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h @@ -18,6 +18,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/cpukit/rtems/include/rtems/rtems/regionimpl.h b/cpukit/rtems/include/rtems/rtems/regionimpl.h index 9ff7b966ca..ae1a50d208 100644 --- a/cpukit/rtems/include/rtems/rtems/regionimpl.h +++ b/cpukit/rtems/include/rtems/rtems/regionimpl.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #ifdef __cplusplus @@ -84,6 +85,7 @@ RTEMS_INLINE_ROUTINE void _Region_Free ( Region_Control *the_region ) { + _Thread_queue_Destroy( &the_region->Wait_queue ); _Objects_Free( &_Region_Information, &the_region->Object ); } diff --git a/cpukit/rtems/src/regioncreate.c b/cpukit/rtems/src/regioncreate.c index 0daf644ce3..aa95f3231b 100644 --- a/cpukit/rtems/src/regioncreate.c +++ b/cpukit/rtems/src/regioncreate.c @@ -71,6 +71,12 @@ rtems_status_code rtems_region_create( return_status = RTEMS_TOO_MANY; else { + _Thread_queue_Initialize( + &the_region->Wait_queue, + _Attributes_Is_priority( attribute_set ) ? + THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO, + RTEMS_TIMEOUT + ); the_region->maximum_segment_size = _Heap_Initialize( &the_region->Memory, starting_address, length, page_size @@ -79,23 +85,13 @@ rtems_status_code rtems_region_create( if ( !the_region->maximum_segment_size ) { _Region_Free( the_region ); return_status = RTEMS_INVALID_SIZE; - } - - else { - + } else { the_region->starting_address = starting_address; the_region->length = length; the_region->page_size = page_size; the_region->attribute_set = attribute_set; the_region->number_of_used_blocks = 0; - _Thread_queue_Initialize( - &the_region->Wait_queue, - _Attributes_Is_priority( attribute_set ) ? - THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO, - RTEMS_TIMEOUT - ); - _Objects_Open( &_Region_Information, &the_region->Object, diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c index 1a52bc1d59..cef90e79f3 100644 --- a/cpukit/rtems/src/regiongetsegment.c +++ b/cpukit/rtems/src/regiongetsegment.c @@ -79,13 +79,10 @@ rtems_status_code rtems_region_get_segment( _Thread_Disable_dispatch(); _RTEMS_Unlock_allocator(); - executing->Wait.queue = &the_region->Wait_queue; executing->Wait.id = id; executing->Wait.count = size; executing->Wait.return_argument = segment; - _Thread_queue_Enter_critical_section( &the_region->Wait_queue ); - _Thread_queue_Enqueue( &the_region->Wait_queue, executing, diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c index a805ac61de..e9c3ad21e9 100644 --- a/cpukit/rtems/src/semdelete.c +++ b/cpukit/rtems/src/semdelete.c @@ -76,12 +76,14 @@ rtems_status_code rtems_semaphore_delete( SEMAPHORE_MP_OBJECT_WAS_DELETED, CORE_MUTEX_WAS_DELETED ); + _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex ); } else { _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, SEMAPHORE_MP_OBJECT_WAS_DELETED, CORE_SEMAPHORE_WAS_DELETED ); + _CORE_semaphore_Destroy( &the_semaphore->Core_control.semaphore ); } _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); -- cgit v1.2.3