summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-06-13 15:06:32 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-06-13 15:06:32 +0000
commitecf0f4c4c18956576aeb69372b93910af7ca37e9 (patch)
treebdc81902ff221b497c67e31822a08dbd69b69a40 /cpukit/posix
parent2008-06-10 Chris Johns <chrisj@rtems.org> (diff)
downloadrtems-ecf0f4c4c18956576aeb69372b93910af7ca37e9.tar.bz2
2008-06-13 Joel Sherrill <joel.sherrill@oarcorp.com>
* posix/include/rtems/posix/pthread.h, posix/src/pthread.c, posix/src/pthreadcreate.c, rtems/include/rtems.h, rtems/src/attr.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, score/inline/rtems/score/stack.inl, score/src/isr.c, score/src/mpci.c, score/src/threadcreateidle.c, score/src/threadinitialize.c, score/src/threadstackallocate.c: Add ability for application to configure minimum stack size. Add RTEMS_CONFIGURED_MINIMUM_STACK_SIZE constant so user can clearly indicate they want the configured as opposed to the recommended minimum stack size.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/include/rtems/posix/pthread.h7
-rw-r--r--cpukit/posix/src/pthread.c2
-rw-r--r--cpukit/posix/src/pthreadcreate.c20
3 files changed, 22 insertions, 7 deletions
diff --git a/cpukit/posix/include/rtems/posix/pthread.h b/cpukit/posix/include/rtems/posix/pthread.h
index 6d0c739f0c..14eaf36c4c 100644
--- a/cpukit/posix/include/rtems/posix/pthread.h
+++ b/cpukit/posix/include/rtems/posix/pthread.h
@@ -27,9 +27,12 @@ extern "C" {
#include <rtems/posix/config.h>
#include <rtems/posix/threadsup.h>
-#define PTHREAD_MINIMUM_STACK_SIZE (STACK_MINIMUM_SIZE * 2)
+/**
+ * The following sets the minimum stack size for POSIX threads.
+ */
+#define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2)
-/*
+/**
* The following defines the information control block used to manage
* this class of objects.
*/
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 53126e2428..a19e2c069c 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -44,7 +44,7 @@
const pthread_attr_t _POSIX_Threads_Default_attributes = {
TRUE, /* is_initialized */
NULL, /* stackaddr */
- PTHREAD_MINIMUM_STACK_SIZE, /* stacksize */
+ 0, /* stacksize -- will be adjusted to minimum */
PTHREAD_SCOPE_PROCESS, /* contentionscope */
PTHREAD_INHERIT_SCHED, /* inheritsched */
SCHED_FIFO, /* schedpolicy */
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 6eeda2da14..c579fb3e14 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -26,6 +26,16 @@
#include <rtems/posix/time.h>
#include <rtems/score/apimutex.h>
+static inline size_t _POSIX_Threads_Ensure_minimum_stack (
+ size_t size
+)
+{
+ if ( size >= PTHREAD_MINIMUM_STACK_SIZE )
+ return size;
+ return PTHREAD_MINIMUM_STACK_SIZE;
+}
+
+
int pthread_create(
pthread_t *thread,
const pthread_attr_t *attr,
@@ -54,11 +64,13 @@ int pthread_create(
return EINVAL;
/*
- * Core Thread Initialize insures we get the minimum amount of
+ * Core Thread Initialize ensures we get the minimum amount of
* stack space if it is allowed to allocate it itself.
+ *
+ * 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 ) )
+ if ( the_attr->stackaddr && !_Stack_Is_enough(the_attr->stacksize) )
return EINVAL;
#if 0
@@ -184,7 +196,7 @@ int pthread_create(
&_POSIX_Threads_Information,
the_thread,
the_attr->stackaddr,
- the_attr->stacksize,
+ _POSIX_Threads_Ensure_minimum_stack(the_attr->stacksize),
is_fp,
core_priority,
TRUE, /* preemptible */