Customize the stack size of the threads used by pupnp through the new THREAD_STACK_SIZE variable
This patch allows a user to customize the stack size of the threads used by
pupnp through the new THREAD_STACK_SIZE variable. This is especially useful
on embedded systems with limited memory where the user can set THREAD_STACK_SIZE
to ITHREAD_STACK_MIN.
However, as this modification can have side effects, I set 0 as the default
value, so threads will continue to use the default stack size of the system
(which varies greatly as stated in
https://computing.llnl.gov/tutorials/pthreads/).
(cherry picked from commit 467f9987a1
)
This commit is contained in:

committed by
Marcelo Roberto Jimenez

parent
ba4ea3bc9b
commit
4a8c4f5c50
@@ -115,6 +115,10 @@ typedef enum priority {
|
||||
#define DEFAULT_MAX_THREADS 10
|
||||
|
||||
|
||||
/*! default stack size used by TPAttrInit */
|
||||
#define DEFAULT_STACK_SIZE 0
|
||||
|
||||
|
||||
/*! default jobs per thread used by TPAttrInit */
|
||||
#define DEFAULT_JOBS_PER_THREAD 10
|
||||
|
||||
@@ -182,6 +186,10 @@ typedef struct THREADPOOLATTR
|
||||
/* maxThreads, ThreadPool will never have more than this number of threads */
|
||||
int maxThreads;
|
||||
|
||||
/* stackSize (in bytes), this is the minimum stack size allocated for each
|
||||
* thread */
|
||||
size_t stackSize;
|
||||
|
||||
/* maxIdleTime (in milliseconds) this is the maximum time a thread will
|
||||
* remain idle before dying */
|
||||
int maxIdleTime;
|
||||
@@ -522,6 +530,20 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
||||
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetStackSize
|
||||
*
|
||||
* Description:
|
||||
* Sets the stack size for the thread pool attributes.
|
||||
* Parameters:
|
||||
* attr - must be valid thread pool attributes.
|
||||
* stackSize - value to set
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetIdleTime
|
||||
*
|
||||
|
Reference in New Issue
Block a user