Changeset ce6e9ec2 in rtems


Ignore:
Timestamp:
06/14/16 04:50:38 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
2df7fcf
Parents:
655ce0fb
git-author:
Sebastian Huber <sebastian.huber@…> (06/14/16 04:50:38)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 12:00:27)
Message:

posix: pthread_mutexattr_setprioceiling()

Accept all priority values in pthread_mutexattr_setprioceiling(). This
is in line with POSIX and FreeBSD. The priority is validated in
pthread_mutex_init(). Validate the priority only for priority ceiling
mutexes.

Files:
4 edited

Legend:

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

    r655ce0fb rce6e9ec2  
    2222#include <pthread.h>
    2323
    24 #include <rtems/system.h>
    25 #include <rtems/score/coremuteximpl.h>
    26 #include <rtems/score/watchdog.h>
    27 #include <rtems/posix/muteximpl.h>
    28 #include <rtems/posix/priorityimpl.h>
    29 
    3024/*
    3125 *  13.6.1 Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128
     
    4034    return EINVAL;
    4135
    42   if ( !_POSIX_Priority_Is_valid( prioceiling ) )
    43     return EINVAL;
    44 
    4536  attr->prio_ceiling = prioceiling;
    4637  return 0;
  • cpukit/posix/src/mutexinit.c

    r655ce0fb rce6e9ec2  
    3737  const pthread_mutexattr_t *the_attr;
    3838  POSIX_Mutex_Protocol       protocol;
     39  Priority_Control           priority;
    3940
    4041  if ( attr ) the_attr = attr;
     
    8788  }
    8889
    89   /*
    90    *  Validate the priority ceiling field -- should always be valid.
    91    */
    92   if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) )
    93     return EINVAL;
    94 
    9590#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
    9691  /*
     
    110105#endif
    111106
     107  if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
     108    if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) ) {
     109      return EINVAL;
     110    }
     111
     112    priority = _POSIX_Priority_To_core( the_attr->prio_ceiling );
     113  }
     114
    112115  the_mutex = _POSIX_Mutex_Allocate();
    113116
     
    120123  the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE );
    121124
    122   switch ( the_mutex->protocol ) {
     125  switch ( protocol ) {
    123126    case POSIX_MUTEX_PRIORITY_CEILING:
    124127      _CORE_ceiling_mutex_Initialize(
    125128        &the_mutex->Mutex,
    126         _POSIX_Priority_To_core( the_attr->prio_ceiling )
     129        priority
    127130      );
    128131      break;
  • testsuites/psxtests/psx05/init.c

    r655ce0fb rce6e9ec2  
    1717#include "system.h"
    1818#include <errno.h>
     19#include <limits.h>
    1920
    2021#include <rtems/score/todimpl.h>
     
    376377  rtems_test_assert( status == EINVAL );
    377378
    378   puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)" );
    379   status = pthread_mutexattr_setprioceiling( &attr, 512 );
    380   if ( status != EINVAL )
    381     printf( "status = %d\n", status );
    382   rtems_test_assert( status == EINVAL );
     379  puts( "Init: pthread_mutexattr_setprioceiling - SUCCESSFUL (priority INT_MAX)" );
     380  status = pthread_mutexattr_setprioceiling( &attr, INT_MAX );
     381  rtems_test_assert( status == 0 );
     382
     383  puts( "Init: pthread_mutexattr_setprioceiling - SUCCESSFUL (priority INT_MIN)" );
     384  status = pthread_mutexattr_setprioceiling( &attr, INT_MIN );
     385  rtems_test_assert( status == 0 );
    383386
    384387  puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)" );
     
    410413  rtems_test_assert( status == EINVAL );
    411414
    412   /* must get around error checks in attribute set routines */
    413   attr.protocol = PTHREAD_PRIO_INHERIT;
    414   attr.prio_ceiling = -1;
     415  puts( "Init: pthread_mutexattr_setprotocol - SUCCESSFUL" );
     416  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT );
     417  rtems_test_assert( !status );
     418
     419  puts( "Init: pthread_mutexattr_setprioceiling - SUCCESSFUL" );
     420  status = pthread_mutexattr_setprioceiling( &attr, -1 );
     421  rtems_test_assert( !status );
    415422
    416423  puts( "Init: pthread_mutex_init - EINVAL (bad priority ceiling)" );
  • testsuites/psxtests/psx05/psx05.scn

    r655ce0fb rce6e9ec2  
    1 *** POSIX TEST 5 ***
     1*** BEGIN OF TEST PSX 5 ***
    22Init's ID is 0x0b010001
    33Init: pthread_mutexattr_init - EINVAL (NULL attr)
     
    2727Init: pthread_mutexattr_getprioceiling - EINVAL (not initialized)
    2828Init: pthread_mutexattr_setprioceiling - EINVAL (NULL attr)
    29 Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)
     29Init: pthread_mutexattr_setprioceiling - SUCCESSFUL (priority INT_MAX)
     30Init: pthread_mutexattr_setprioceiling - SUCCESSFUL (priority INT_MIN)
    3031Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)
    3132
     
    3334Init: pthread_mutex_init - EINVAL (not initialized attr)
    3435Init: pthread_mutex_init - EINVAL (bad protocol)
     36Init: pthread_mutexattr_setprotocol - SUCCESSFUL
     37Init: pthread_mutexattr_setprioceiling - SUCCESSFUL
    3538Init: pthread_mutex_init - EINVAL (bad priority ceiling)
    3639Init: Resetting mutex attributes
     
    8386Init: pthread_setschedparam - Setting Task2 priority to highest
    8487Task 2: pthread_mutex_lock unavailable (inherit case)
    85 Init: pthread_getschedparam - priority = 254
     88Init: pthread_getschedparam - priority = 2
    8689Init: pthread_mutex_unlock - SUCCESSFUL
    8790Task 2: mutex acquired
     
    104107Init: pthread_getschedparam - priority = 2
    105108Init: pthread_mutex_trylock - SUCCESSFUL
    106 Init: pthread_getschedparam - priority = 200
     109Init: pthread_getschedparam - priority = 2
    107110Init: pthread_setschedparam - set Task3 priority to highest
    108111Init: Sleep 1 second
     
    117120Init: pthread_mutex_lock - EINVAL (priority ceiling violation)
    118121Init: Recursive Mutex
    119 *** END OF POSIX TEST 5 ***
     122*** END OF TEST PSX 5 ***
Note: See TracChangeset for help on using the changeset viewer.