[PATCH 2/6] posix/shm: replace threadq with mutex (allocator lock)

Gedare Bloom gedare at rtems.org
Fri Mar 31 20:47:00 UTC 2017


Closes #2957.
---
 cpukit/posix/include/rtems/posix/shmimpl.h | 19 -------------------
 cpukit/posix/src/shmopen.c                 | 14 +++++---------
 2 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/shmimpl.h b/cpukit/posix/include/rtems/posix/shmimpl.h
index ff3299e..6d81e5e 100644
--- a/cpukit/posix/include/rtems/posix/shmimpl.h
+++ b/cpukit/posix/include/rtems/posix/shmimpl.h
@@ -33,25 +33,6 @@ extern "C" {
 
 extern Objects_Information _POSIX_Shm_Information;
 
-RTEMS_INLINE_ROUTINE void _POSIX_Shm_Acquire(
-  POSIX_Shm_Control                 *the_shm,
-  Thread_queue_Context              *queue_context
-)
-{
-  _Thread_queue_Acquire(
-    &the_shm->Wait_queue,
-    queue_context
-  );
-}
-
-RTEMS_INLINE_ROUTINE void _POSIX_Shm_Release(
-  POSIX_Shm_Control                 *the_shm,
-  Thread_queue_Context              *queue_context
-)
-{
-  _Thread_queue_Release( &the_shm->Wait_queue, queue_context );
-}
-
 RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
 {
   return (POSIX_Shm_Control *)
diff --git a/cpukit/posix/src/shmopen.c b/cpukit/posix/src/shmopen.c
index 4c86535..bedde15 100644
--- a/cpukit/posix/src/shmopen.c
+++ b/cpukit/posix/src/shmopen.c
@@ -55,42 +55,38 @@ static int shm_fstat(
 /* read() is unspecified for shared memory objects */
 static ssize_t shm_read( rtems_libio_t *iop, void *buffer, size_t count )
 {
-  Thread_queue_Context queue_context;
   ssize_t bytes_read;
   POSIX_Shm_Control *shm = iop_to_shm( iop );
 
-  _Thread_queue_Context_initialize( &queue_context );
-  _POSIX_Shm_Acquire( shm, &queue_context );
+  _Objects_Allocator_lock();
   bytes_read = (*shm->shm_object.ops->object_read)(
       &shm->shm_object,
       buffer,
       count
   );
   _POSIX_Shm_Update_atime( shm );
-  _POSIX_Shm_Release( shm, &queue_context );
 
+  _Objects_Allocator_unlock();
   return bytes_read;
 }
 
 static int shm_ftruncate( rtems_libio_t *iop, off_t length )
 {
-  Thread_queue_Context queue_context;
   int err;
   POSIX_Shm_Control *shm = iop_to_shm( iop );
 
-  _Thread_queue_Context_initialize( &queue_context );
-  _POSIX_Shm_Acquire( shm, &queue_context );
+  _Objects_Allocator_lock();
 
   err = (*shm->shm_object.ops->object_resize)( &shm->shm_object, length );
 
   if ( err != 0 ) {
-    _POSIX_Shm_Release( shm, &queue_context );
+    _Objects_Allocator_unlock();
     rtems_set_errno_and_return_minus_one( err );
   }
 
   _POSIX_Shm_Update_mtime_ctime( shm );
 
-  _POSIX_Shm_Release( shm, &queue_context );
+  _Objects_Allocator_unlock();
   return 0;
 }
 
-- 
2.7.4




More information about the devel mailing list