Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POSIX port - Switch from allowing the user to specify the stack memor…
…y itself, to allowing them to specify the stack size Change from pthread_attr_setstack() to pthread_attr_setstacksize(), and automatically adjust the stack size to be at least PTHREAD_STACK_MIN if it wasn't already, removing the size warning. This permits the user to increase the pthread stack size beyond the PTHREAD_STACK_MIN default of 16384 if desired, without producing a warning in the typical case where stacks are minimized for RAM limited targets. Continue to store thread paramters on the provided stack, for consistency with the MCU targets. Previously pthread_attr_setstack() was used to enable user defined stacks. Note that: 1. The stack size can still be specified by the user. 2. pxPortInitialiseStack(), and pthread_addr_setstack() was failing on stacks of typical size, as these are smaller than PTHREAD_STACK_MIN (16384) bytes, and printing out a series of warnings. Improve usability by having the posix port automatically increase the stack size to be at least PTHREAD_STACK_MIN as posix platforms have enough memory for this not to be a concern. 3. Reuse of stack memory will also result in valgrind 'invalid write' errors to what is demonstrably valid memory. Root cause is that Valgrind is tracking a stack pointer as the stack is used. Reuse of a stack buffer results in the stack being used at its start, in an area that Valgrind thinks is far away from the start of the stack. There are ways to notify Valgrind of these changes however this would require linking against and calling Valgrind functions from the FreeRTOS application using the posix port, https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq. Also, apparently it isn't permitted by posix to reuse stack memory once its been used in a pthread via pthread_attr_setstack(), see https://stackoverflow.com/a/5422134
- Loading branch information