From 314c77609ea716060197354a10282f53daf44c93 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Tue, 26 Feb 2019 16:55:20 +0100 Subject: [PATCH] pthread: Transform the units of the stack size to the FreeRTOS domain Closes https://github.com/espressif/esp-idf/issues/3015 --- components/pthread/pthread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index a1ae6d440e..2250c4075c 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -286,7 +286,11 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, pthread->task_arg = task_arg; BaseType_t res = xTaskCreatePinnedToCore(&pthread_task_func, task_name, - stack_size, + // stack_size is in bytes. This transformation ensures that the units are + // transformed to the units used in FreeRTOS. + // Note: float division of ceil(m / n) == + // integer division of (m + n - 1) / n + (stack_size + sizeof(StackType_t) - 1) / sizeof(StackType_t), task_arg, prio, &xHandle,