diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-10-11 12:53:52 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-10-11 13:22:12 +0200 |
commit | d61fbeda590936ee03e91cf4b200f24d613e6ec2 (patch) | |
tree | 4f889be01b138f1c41d6bc90d2cd4885c06347be | |
parent | libdl/rtl-mdreloc-h8300.c: Remove remnant of h8300 port (diff) | |
download | rtems-d61fbeda590936ee03e91cf4b200f24d613e6ec2.tar.bz2 |
score: _Thread_queue_Surrender_priority_ceiling()
Do not use a direct thread dispatch in
_Thread_queue_Surrender_priority_ceiling() since it may be used in condition
variables using POSIX mutexes.
Close #4526.
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 4 | ||||
-rw-r--r-- | testsuites/psxtests/psx05/init.c | 43 |
2 files changed, 45 insertions, 2 deletions
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index b3bf5512ac..5fc357ec82 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -818,7 +818,7 @@ Status_Control _Thread_queue_Surrender_priority_ceiling( &queue_context->Lock_context.Lock_context ); _Thread_Priority_update( queue_context ); - _Thread_Dispatch_direct( cpu_self ); + _Thread_Dispatch_enable( cpu_self ); return STATUS_SUCCESSFUL; } @@ -856,7 +856,7 @@ Status_Control _Thread_queue_Surrender_priority_ceiling( unblock ); - _Thread_Dispatch_direct( cpu_self ); + _Thread_Dispatch_enable( cpu_self ); return STATUS_SUCCESSFUL; } diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c index 2459166321..4c1603daf3 100644 --- a/testsuites/psxtests/psx05/init.c +++ b/testsuites/psxtests/psx05/init.c @@ -406,6 +406,48 @@ static void test_mutex_auto_initialization( void ) } } +static void test_mutex_prio_protect_with_cv( void ) +{ + pthread_mutex_t mutex; + pthread_mutexattr_t attr; + pthread_cond_t cond; + int eno; + struct timespec timeout; + + eno = pthread_mutexattr_init( &attr ); + rtems_test_assert( eno == 0 ); + + eno = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT ); + rtems_test_assert( eno == 0 ); + + eno = pthread_mutex_init( &mutex, &attr ); + rtems_test_assert( eno == 0 ); + + eno = pthread_mutexattr_destroy( &attr ); + rtems_test_assert( eno == 0 ); + + eno = pthread_cond_init( &cond, NULL ); + rtems_test_assert( eno == 0 ); + + eno = pthread_mutex_lock( &mutex ); + rtems_test_assert( eno == 0 ); + + timeout.tv_sec = 0; + timeout.tv_nsec = 0; + + eno = pthread_cond_timedwait( &cond, &mutex, &timeout ); + rtems_test_assert( eno == ETIMEDOUT ); + + eno = pthread_mutex_unlock( &mutex ); + rtems_test_assert( eno == 0 ); + + eno = pthread_mutex_destroy( &mutex ); + rtems_test_assert( eno == 0 ); + + eno = pthread_cond_destroy( &cond ); + rtems_test_assert( eno == 0 ); +} + void *POSIX_Init( void *argument ) @@ -431,6 +473,7 @@ void *POSIX_Init( test_mutex_not_initialized(); test_mutex_invalid_copy(); test_mutex_auto_initialization(); + test_mutex_prio_protect_with_cv(); test_get_priority(); test_set_priority(); test_errors_pthread_setschedprio(); |