px4_work_queue: stack size rounded to page size on posix

This commit is contained in:
FlavioTonelli 2019-11-03 15:04:04 +01:00 committed by Daniel Agar
parent a08abccdd5
commit 7984c0c910

View File

@ -203,10 +203,16 @@ WorkQueueManagerRun(int, char **)
}
// stack size
#ifndef __PX4_QURT
const size_t stacksize = math::max(PTHREAD_STACK_MIN, PX4_STACK_ADJUSTED(wq->stacksize));
#else
#if defined(__PX4_QURT)
const size_t stacksize = math::max(8 * 1024, PX4_STACK_ADJUSTED(wq->stacksize));
#elif defined(__PX4_NUTTX)
const size_t stacksize = math::max((uint16_t)PTHREAD_STACK_MIN, wq->stacksize);
#elif defined(__PX4_POSIX)
// On posix system , the desired stacksize round to the nearest multiplier of the system pagesize
// It is a requirement of the pthread_attr_setstacksize* function
const unsigned int page_size = sysconf(_SC_PAGESIZE);
const size_t stacksize_adj = math::max(PTHREAD_STACK_MIN, PX4_STACK_ADJUSTED(wq->stacksize));
const size_t stacksize = (stacksize_adj + page_size - (stacksize_adj % page_size));
#endif
int ret_setstacksize = pthread_attr_setstacksize(&attr, stacksize);