Changeset 8cdf733 in rtems


Ignore:
Timestamp:
Jul 6, 2009, 2:46:36 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
81551a2
Parents:
70a4809
Message:

2009-07-06 Joel Sherrill <joel.sherrill@…>

  • posix/Makefile.am, posix/src/mutex.c, posix/src/mutexinit.c: Add initial support for the pthread mutex type attribute added by UNIX98. It can be normal, recursive, errorcheck or default.
  • posix/src/mutexattrgettype.c, posix/src/mutexattrsettype.c: New files.
Location:
cpukit
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r70a4809 r8cdf733  
     12009-07-06      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * posix/Makefile.am, posix/src/mutex.c, posix/src/mutexinit.c: Add
     4        initial support for the pthread mutex type attribute added by UNIX98.
     5        It can be normal, recursive, errorcheck or default.
     6        * posix/src/mutexattrgettype.c, posix/src/mutexattrsettype.c: New files.
     7
    182009-07-04      Joel Sherrill <joel.sherrill@OARcorp.com>
    29
  • cpukit/posix/Makefile.am

    r70a4809 r8cdf733  
    9898
    9999## MUTEX_C_FILES
    100 libposix_a_SOURCES += src/mutex.c src/mutexattrdestroy.c \
    101     src/mutexattrgetprioceiling.c src/mutexattrgetprotocol.c \
    102     src/mutexattrgetpshared.c src/mutexattrinit.c \
    103     src/mutexattrsetprioceiling.c src/mutexattrsetprotocol.c \
    104     src/mutexattrsetpshared.c src/mutexdestroy.c \
     100libposix_a_SOURCES += src/mutexattrdestroy.c src/mutexattrgetprioceiling.c \
     101    src/mutexattrgetprotocol.c src/mutexattrgetpshared.c \
     102    src/mutexattrgettype.c src/mutexattrinit.c src/mutexattrsetprioceiling.c \
     103    src/mutexattrsetprotocol.c src/mutexattrsetpshared.c \
     104    src/mutexattrsettype.c src/mutex.c src/mutexdestroy.c src/mutexget.c \
    105105    src/mutexgetprioceiling.c src/mutexinit.c src/mutexlock.c \
    106106    src/mutexlocksupp.c src/mutexsetprioceiling.c src/mutextimedlock.c \
    107     src/mutextranslatereturncode.c src/mutextrylock.c src/mutexunlock.c \
    108     src/mutexget.c
     107    src/mutextranslatereturncode.c src/mutextrylock.c src/mutexunlock.c
    109108
    110109## PTHREAD_C_FILES
  • cpukit/posix/src/mutex.c

    r70a4809 r8cdf733  
    5454  default_attr->protocol       = PTHREAD_PRIO_NONE;
    5555  default_attr->recursive      = false;
     56  #if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
     57    default_attr->type         = PTHREAD_MUTEX_DEFAULT;
     58  #endif
    5659
    5760  /*
  • cpukit/posix/src/mutexinit.c

    r70a4809 r8cdf733  
    4141  const pthread_mutexattr_t    *the_attr;
    4242  CORE_mutex_Disciplines        the_discipline;
    43 #if 0
    44   register POSIX_Mutex_Control *mutex_in_use;
    45   Objects_Locations             location;
    46 #endif
    4743
    4844  if ( attr ) the_attr = attr;
     
    7167   *
    7268   *  Joel Sherrill <joel@OARcorp.com>     14 May 1999
     69   *  NOTE: Be careful to avoid infinite recursion on call to this
     70   *        routine in _POSIX_Mutex_Get.
    7371   */
    74 #if 0
    75   /* avoid infinite recursion on call to this routine in _POSIX_Mutex_Get */
     72  #if 0
     73  {
     74    POSIX_Mutex_Control *mutex_in_use;
     75    Objects_Locations    location;
    7676
    77   if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
     77    if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
    7878
    79     /* EBUSY if *mutex is a valid id */
     79      /* EBUSY if *mutex is a valid id */
    8080
    81     mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
    82     switch ( location ) {
    83       case OBJECTS_LOCAL:
    84         _Thread_Enable_dispatch();
    85         return EBUSY;
    86 #if defined(RTEMS_MULTIPROCESSING)
    87       case OBJECTS_REMOTE:
    88 #endif
    89       case OBJECTS_ERROR:
    90         break;
     81      mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
     82      switch ( location ) {
     83        case OBJECTS_LOCAL:
     84          _Thread_Enable_dispatch();
     85          return EBUSY;
     86        #if defined(RTEMS_MULTIPROCESSING)
     87          case OBJECTS_REMOTE:
     88        #endif
     89        case OBJECTS_ERROR:
     90          break;
     91      }
    9192    }
    9293  }
    93 #endif
     94  #endif
    9495
    9596  if ( !the_attr->is_initialized )
     
    122123  }
    123124
     125  /*
     126   *  Validate the priority ceiling field -- should always be valid.
     127   */
    124128  if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) )
    125129    return EINVAL;
     130
     131#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
     132  /*
     133   *  Validate the mutex type and set appropriate SuperCore mutex
     134   *  attributes.
     135   */
     136  switch ( the_attr->type ) {
     137    case PTHREAD_MUTEX_NORMAL:
     138    case PTHREAD_MUTEX_RECURSIVE:
     139    case PTHREAD_MUTEX_ERRORCHECK:
     140    case PTHREAD_MUTEX_DEFAULT:
     141      break;
     142
     143    default:
     144      return EINVAL;
     145  }
     146#endif
    126147
    127148  /*
Note: See TracChangeset for help on using the changeset viewer.