diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-27 09:03:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-28 13:09:43 +0200 |
commit | 1d572eba9748f815486258b2e87d831e5bdee038 (patch) | |
tree | ff707cbe761c948987d58a178d77f87667889371 /cpukit/posix/src/pthreadcreate.c | |
parent | score: Simplify SMP get lowest scheduled (diff) | |
download | rtems-1d572eba9748f815486258b2e87d831e5bdee038.tar.bz2 |
posix: Fix pthread_create() with user stack
In case the user provides a stack with address and size, then do not
alter the stack size.
Close #3211.
Diffstat (limited to 'cpukit/posix/src/pthreadcreate.c')
-rw-r--r-- | cpukit/posix/src/pthreadcreate.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 2315b7f5ee..5a8cf2d7fb 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -77,6 +77,7 @@ int pthread_create( const POSIX_API_Control *executing_api; int schedpolicy = SCHED_RR; struct sched_param schedparam; + size_t stacksize; Objects_Name name; int error; ISR_lock_Context lock_context; @@ -96,8 +97,15 @@ int pthread_create( * NOTE: If the user provides the stack we will let it drop below * twice the minimum. */ - if ( the_attr->stackaddr && !_Stack_Is_enough(the_attr->stacksize) ) - return EINVAL; + if ( the_attr->stackaddr != NULL ) { + if ( !_Stack_Is_enough(the_attr->stacksize) ) { + return EINVAL; + } + + stacksize = the_attr->stacksize; + } else { + stacksize = _POSIX_Threads_Ensure_minimum_stack( the_attr->stacksize ); + } #if 0 int cputime_clock_allowed; /* see time.h */ @@ -200,7 +208,7 @@ int pthread_create( the_thread, scheduler, the_attr->stackaddr, - _POSIX_Threads_Ensure_minimum_stack(the_attr->stacksize), + stacksize, is_fp, core_normal_prio, true, /* preemptible */ |