[rtems commit] posix: Fix _POSIX_Threads_Create_extension()
Sebastian Huber
sebh at rtems.org
Tue Oct 17 08:12:37 UTC 2017
Module: rtems
Branch: master
Commit: 2fcea4c47325578d887d2c061a86e5e178d7a32a
Changeset: http://git.rtems.org/rtems/commit/?id=2fcea4c47325578d887d2c061a86e5e178d7a32a
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Oct 17 10:06:08 2017 +0200
posix: Fix _POSIX_Threads_Create_extension()
The thread POSIX API control must be fully initialized in
_POSIX_Threads_Create_extension(), otherwise a pthread_setschedparam()
is broken for all threads not created with pthread_create().
---
cpukit/posix/src/pthread.c | 1 +
cpukit/posix/src/pthreadcreate.c | 3 +--
testsuites/psxtests/psxclassic01/init.c | 8 ++++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 30b830c..9d1c1ad 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -151,6 +151,7 @@ static bool _POSIX_Threads_Create_extension(
_Watchdog_Preinitialize( &api->Sporadic.Timer, _Per_CPU_Get_by_index( 0 ) );
_Watchdog_Initialize( &api->Sporadic.Timer, _POSIX_Threads_Sporadic_timer );
+ _Priority_Node_set_inactive( &api->Sporadic.Low_priority );
return true;
}
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 75205f7..d8cafe5 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -242,8 +242,7 @@ int pthread_create(
( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED );
api->schedpolicy = the_attr->schedpolicy;
api->schedparam = the_attr->schedparam;
- _Priority_Node_initialize( &api->Sporadic.Low_priority, core_low_prio );
- _Priority_Node_set_inactive( &api->Sporadic.Low_priority );
+ _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
if ( schedpolicy == SCHED_SPORADIC ) {
_POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer );
diff --git a/testsuites/psxtests/psxclassic01/init.c b/testsuites/psxtests/psxclassic01/init.c
index 924224c..1acc141 100644
--- a/testsuites/psxtests/psxclassic01/init.c
+++ b/testsuites/psxtests/psxclassic01/init.c
@@ -52,9 +52,17 @@ rtems_task test_task(rtems_task_argument arg)
int sc;
struct sigaction new_action;
sigset_t mask;
+ int policy;
+ struct sched_param param;
printf("test_task starting...\n");
+ sc = pthread_getschedparam( pthread_self(), &policy, ¶m );
+ rtems_test_assert( sc == 0 );
+
+ sc = pthread_setschedparam( pthread_self(), policy, ¶m );
+ rtems_test_assert( sc == 0 );
+
sc = sigemptyset (&new_action.sa_mask);
rtems_test_assert( sc == 0 );
More information about the vc
mailing list