summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-09 13:57:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-12 09:08:36 +0100
commita08dcb2f7c7c883559e10c389404a4dc751376fa (patch)
tree6cea52738a5a38cc7a2fc3260e88fe2a9a37e287 /cpukit/posix/src
parent00c7ad4cab30aba80639ace29526c1efc2779074 (diff)
downloadrtems-a08dcb2f7c7c883559e10c389404a4dc751376fa.tar.bz2
score: Add Thread_Configuration
Add the Thread_Configuration structure to reduce the parameter count of _Thread_Initialize(). This makes it easier to add more parameters in the future. It simplifies the code generation since most architectures do not have that many registers available for function parameters. Update #3835.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/pthreadcreate.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 47a408b333..2a418c4b68 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -39,6 +39,8 @@
#include <rtems/score/userextimpl.h>
#include <rtems/sysinit.h>
+#include <string.h>
+
static inline size_t _POSIX_Threads_Ensure_minimum_stack (
size_t size
)
@@ -68,18 +70,12 @@ int pthread_create(
const pthread_attr_t *the_attr;
int normal_prio;
bool valid;
- Priority_Control core_normal_prio;
- Thread_CPU_budget_algorithms budget_algorithm;
- Thread_CPU_budget_algorithm_callout budget_callout;
- bool is_fp;
+ Thread_Configuration config;
bool status;
Thread_Control *the_thread;
Thread_Control *executing;
- const Scheduler_Control *scheduler;
int schedpolicy = SCHED_RR;
struct sched_param schedparam;
- size_t stacksize;
- Objects_Name name;
int error;
ISR_lock_Context lock_context;
#if defined(RTEMS_POSIX_API)
@@ -96,11 +92,15 @@ int pthread_create(
if ( !the_attr->is_initialized )
return EINVAL;
+ memset( &config, 0, sizeof( config ) );
+
/*
* Currently all POSIX threads are floating point if the hardware
* supports it.
*/
- is_fp = true;
+ config.is_fp = true;
+
+ config.is_preemptible = true;
/*
* Core Thread Initialize ensures we get the minimum amount of
@@ -110,13 +110,16 @@ int pthread_create(
* twice the minimum.
*/
if ( the_attr->stackaddr != NULL ) {
- if ( !_Stack_Is_enough( the_attr->stacksize, is_fp ) ) {
+ if ( !_Stack_Is_enough( the_attr->stacksize, config.is_fp ) ) {
return EINVAL;
}
- stacksize = the_attr->stacksize;
+ config.stack_area = the_attr->stackaddr;
+ config.stack_size = the_attr->stacksize;
} else {
- stacksize = _POSIX_Threads_Ensure_minimum_stack( the_attr->stacksize );
+ config.stack_size = _POSIX_Threads_Ensure_minimum_stack(
+ the_attr->stacksize
+ );
}
#if 0
@@ -164,8 +167,8 @@ int pthread_create(
error = _POSIX_Thread_Translate_sched_param(
schedpolicy,
&schedparam,
- &budget_algorithm,
- &budget_callout
+ &config.budget_algorithm,
+ &config.budget_callout
);
if ( error != 0 ) {
return error;
@@ -173,9 +176,13 @@ int pthread_create(
normal_prio = schedparam.sched_priority;
- scheduler = _Thread_Scheduler_get_home( executing );
+ config.scheduler = _Thread_Scheduler_get_home( executing );
- core_normal_prio = _POSIX_Priority_To_core( scheduler, normal_prio, &valid );
+ config.priority = _POSIX_Priority_To_core(
+ config.scheduler,
+ normal_prio,
+ &valid
+ );
if ( !valid ) {
return EINVAL;
}
@@ -187,7 +194,7 @@ int pthread_create(
low_prio = normal_prio;
}
- core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
+ core_low_prio = _POSIX_Priority_To_core( config.scheduler, low_prio, &valid );
if ( !valid ) {
return EINVAL;
}
@@ -211,20 +218,10 @@ int pthread_create(
/*
* Initialize the core thread for this task.
*/
- name.name_p = NULL; /* posix threads don't have a name by default */
status = _Thread_Initialize(
&_POSIX_Threads_Information,
the_thread,
- scheduler,
- the_attr->stackaddr,
- stacksize,
- is_fp,
- core_normal_prio,
- true, /* preemptible */
- budget_algorithm,
- budget_callout,
- 0, /* isr level */
- name /* posix threads don't have a name */
+ &config
);
if ( !status ) {
_POSIX_Threads_Free( the_thread );