#2975 new defect

Enhance support for POSIX mutex types

Reported by: Joel Sherrill Owned by:
Priority: normal Milestone: Indefinite
Component: unspecified Version:
Severity: normal Keywords: POSIX-Compliance
Cc: Blocked By:
Blocking:

Description

POSIX defines four mutex types (http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_gettype.html):

  • PTHREAD_MUTEX_NORMAL
  • PTHREAD_MUTEX_ERRORCHECK
  • PTHREAD_MUTEX_RECURSIVE
  • PTHREAD_MUTEX_DEFAULT

Currently RTEMS treats all as the same. But the score mutex should support enough to make the distinctions possible.

I am sure the current POSIX standard has a description of each but this is older POSIX link also describes them: http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutexattr_settype.html

The type of mutex is contained in the type attribute of the mutex attributes. Valid mutex types include:

  • PTHREAD_MUTEX_NORMAL: This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking it will deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behaviour. Attempting to unlock an unlocked mutex results in undefined behaviour.
  • PTHREAD_MUTEX_ERRORCHECK: This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking it will return with an error. A thread attempting to unlock a mutex which another thread has locked will return with an error. A thread attempting to unlock an unlocked mutex will return with an error.
  • PTHREAD_MUTEX_RECURSIVE: A thread attempting to relock this mutex without first unlocking it will succeed in locking the mutex. The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. Multiple locks of this mutex require the same number of unlocks to release the mutex before another thread can acquire the mutex. A thread attempting to unlock a mutex which another thread has locked will return with an error. A thread attempting to unlock an unlocked mutex will return with an error.
  • PTHREAD_MUTEX_DEFAULT: Attempting to recursively lock a mutex of this type results in undefined behaviour. Attempting to unlock a mutex of this type which was not locked by the calling thread results in undefined behaviour. Attempting to unlock a mutex of this type which is not locked results in undefined behaviour. An implementation is allowed to map this mutex to one of the other mutex types.

Change History (2)

comment:1 Changed on 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:2 Changed on 06/08/17 at 07:33:19 by Sebastian Huber

Milestone: 4.12.0Indefinite
Version: 4.12
Note: See TracTickets for help on using tickets.