posix/shm: replace threadq with mutex (allocator lock)

Closes #2957.
This commit is contained in:
Gedare Bloom
2017-03-31 15:23:47 -04:00
parent 889eb76731
commit bd9d5ebc33
2 changed files with 5 additions and 28 deletions

View File

@@ -33,25 +33,6 @@ extern "C" {
extern Objects_Information _POSIX_Shm_Information; 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 ) RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
{ {
return (POSIX_Shm_Control *) return (POSIX_Shm_Control *)

View File

@@ -55,42 +55,38 @@ static int shm_fstat(
/* read() is unspecified for shared memory objects */ /* read() is unspecified for shared memory objects */
static ssize_t shm_read( rtems_libio_t *iop, void *buffer, size_t count ) static ssize_t shm_read( rtems_libio_t *iop, void *buffer, size_t count )
{ {
Thread_queue_Context queue_context;
ssize_t bytes_read; ssize_t bytes_read;
POSIX_Shm_Control *shm = iop_to_shm( iop ); POSIX_Shm_Control *shm = iop_to_shm( iop );
_Thread_queue_Context_initialize( &queue_context ); _Objects_Allocator_lock();
_POSIX_Shm_Acquire( shm, &queue_context );
bytes_read = (*shm->shm_object.ops->object_read)( bytes_read = (*shm->shm_object.ops->object_read)(
&shm->shm_object, &shm->shm_object,
buffer, buffer,
count count
); );
_POSIX_Shm_Update_atime( shm ); _POSIX_Shm_Update_atime( shm );
_POSIX_Shm_Release( shm, &queue_context );
_Objects_Allocator_unlock();
return bytes_read; return bytes_read;
} }
static int shm_ftruncate( rtems_libio_t *iop, off_t length ) static int shm_ftruncate( rtems_libio_t *iop, off_t length )
{ {
Thread_queue_Context queue_context;
int err; int err;
POSIX_Shm_Control *shm = iop_to_shm( iop ); POSIX_Shm_Control *shm = iop_to_shm( iop );
_Thread_queue_Context_initialize( &queue_context ); _Objects_Allocator_lock();
_POSIX_Shm_Acquire( shm, &queue_context );
err = (*shm->shm_object.ops->object_resize)( &shm->shm_object, length ); err = (*shm->shm_object.ops->object_resize)( &shm->shm_object, length );
if ( err != 0 ) { if ( err != 0 ) {
_POSIX_Shm_Release( shm, &queue_context ); _Objects_Allocator_unlock();
rtems_set_errno_and_return_minus_one( err ); rtems_set_errno_and_return_minus_one( err );
} }
_POSIX_Shm_Update_mtime_ctime( shm ); _POSIX_Shm_Update_mtime_ctime( shm );
_POSIX_Shm_Release( shm, &queue_context ); _Objects_Allocator_unlock();
return 0; return 0;
} }