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().
This commit is contained in:
Sebastian Huber
2017-10-17 10:06:08 +02:00
parent 91ce012ced
commit 2fcea4c473
3 changed files with 10 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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 );

View File

@@ -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, &param );
rtems_test_assert( sc == 0 );
sc = pthread_setschedparam( pthread_self(), policy, &param );
rtems_test_assert( sc == 0 );
sc = sigemptyset (&new_action.sa_mask);
rtems_test_assert( sc == 0 );