Changeset 48b04fc3 in rtems for cpukit/posix/src/mutexdestroy.c


Ignore:
Timestamp:
Apr 19, 2016, 4:28:03 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
adbedd1
Parents:
bbe654af
git-author:
Sebastian Huber <sebastian.huber@…> (04/19/16 04:28:03)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/21/16 05:29:39)
Message:

posix: Avoid Giant lock for mutexes

Delete _POSIX_Mutex_Get(). Use _POSIX_Mutex_Get_interrupt_disable()
instead.

Update #2555.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/mutexdestroy.c

    rbbe654af r48b04fc3  
    1919#endif
    2020
    21 #include <errno.h>
    22 #include <pthread.h>
    23 
    24 #include <rtems/system.h>
    25 #include <rtems/score/coremuteximpl.h>
    26 #include <rtems/score/watchdog.h>
    2721#include <rtems/posix/muteximpl.h>
    28 #include <rtems/posix/priorityimpl.h>
    2922
    3023/*
     
    3629)
    3730{
    38   register POSIX_Mutex_Control *the_mutex;
    39   Objects_Locations             location;
     31  POSIX_Mutex_Control *the_mutex;
     32  ISR_lock_Context     lock_context;
     33  int                  eno;
    4034
    4135  _Objects_Allocator_lock();
    42   the_mutex = _POSIX_Mutex_Get( mutex, &location );
    43   switch ( location ) {
    4436
    45     case OBJECTS_LOCAL:
    46        /*
    47         * XXX: There is an error for the mutex being locked
    48         *  or being in use by a condition variable.
    49         */
     37  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context );
    5038
    51       if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
    52         _Objects_Put( &the_mutex->Object );
    53         _Objects_Allocator_unlock();
    54         return EBUSY;
    55       }
     39  if ( the_mutex != NULL ) {
     40    _CORE_mutex_Acquire_critical( &the_mutex->Mutex, &lock_context );
    5641
     42    /*
     43     * XXX: There is an error for the mutex being locked
     44     *  or being in use by a condition variable.
     45     */
     46
     47    if ( !_CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
    5748      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
    58       _CORE_mutex_Flush( &the_mutex->Mutex, EINVAL, NULL, 0 );
    59       _Objects_Put( &the_mutex->Object );
     49      _CORE_mutex_Release( &the_mutex->Mutex, &lock_context );
     50      _CORE_mutex_Destroy( &the_mutex->Mutex );
    6051      _POSIX_Mutex_Free( the_mutex );
    61       _Objects_Allocator_unlock();
    62 
    63       return 0;
    64 
    65 #if defined(RTEMS_MULTIPROCESSING)
    66     case OBJECTS_REMOTE:
    67 #endif
    68     case OBJECTS_ERROR:
    69       break;
     52      eno = 0;
     53    } else {
     54      _CORE_mutex_Release( &the_mutex->Mutex, &lock_context );
     55      eno = EBUSY;
     56    }
     57  } else {
     58    eno = EINVAL;
    7059  }
    7160
    7261  _Objects_Allocator_unlock();
    73 
    74   return EINVAL;
     62  return eno;
    7563}
Note: See TracChangeset for help on using the changeset viewer.