# Problems with FreeRTOS and Posix

**URL:** <https://forums.freertos.org/t/problems-with-freertos-and-posix/11271>\
**Category:** Kernel\
**Created:** [December 4, 2020, 6:23pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271 "2020-12-04T18:23:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dadodasilva](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dadodasilva](https://forums.freertos.org/u/dadodasilva)\
**Post date:** [December 4, 2020, 6:23pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/1 "2020-12-04T18:23:44Z")

</div>

Hello guys!  
I had some problems using pthread\_create to create first task of my system.  
So I change this to use xTaskCreate.  
Someone can help me, why can I not use posix to create the first thread?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [December 4, 2020, 6:37pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/2 "2020-12-04T18:37:28Z")

</div>

Which hardware platform are you using? Where did you get the POSIX wrapper for FreeRTOS? Is it possible to share code?

Thanks.

---

<div class="post-metadata">

**Author:** ![dadodasilva](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dadodasilva](https://forums.freertos.org/u/dadodasilva)\
**Post date:** [December 4, 2020, 6:52pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/3 "2020-12-04T18:52:27Z")

</div>

I’m using STM32F427 and IAR compiler.  
We used this page to add FreeRTOS + Posix.

> **[FreeRTOS + POSIX - FreeRTOS](https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_POSIX/index.html)**
>
> NOTE: The POSIX library and documentation are in the FreeRTOS Labs.  The libraries in the FreeRTOS Labs download directory are fully functional, but undergoing optimizations or refactoring to improve memory usage, modularity, documentation, demo...

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [December 4, 2020, 7:16pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/4 "2020-12-04T19:16:28Z")

</div>

What is the error that you are getting? `pthread_create` eventually calls `xTaskCreate`: [https://github.com/FreeRTOS/Lab-Project-FreeRTOS-POSIX/blob/master/FreeRTOS-Plus-POSIX/source/FreeRTOS\_POSIX\_pthread.c#L341](https://github.com/FreeRTOS/Lab-Project-FreeRTOS-POSIX/blob/master/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c#L341)

Would you please step through the code and see what are the differences in the parameters passed to `xtaskCreate`?

Thanks.

---

<div class="post-metadata">

**Author:** ![santhanraghava](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@santhanraghava](https://forums.freertos.org/u/santhanraghava)\
**Post date:** [January 5, 2023, 12:31am UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/5 "2023-01-05T00:31:57Z")

</div>

I am trying to integrate POSIX on FreeRTOS for STM32F4 board. Currently i am facing implicit declaration of static functions like xSemaphoreCreateMutexStatic, xEventGroupCreateStatic, etc. I want to not use static functions but use freertos heap memory. These functions are not present in the source code itself. Please let me know what to do.

I am using posix demo project : FreeRTOS-Plus-POSIX.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [January 6, 2023, 6:49am UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/6 "2023-01-06T06:49:44Z")

</div>

These functions come from [semphr.h](https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/include/semphr.h#L798) file. Have you tried including this file in your source -

```auto
#include "FreeRTOS.h"
#include "semphr.h"

```

Separately, why do you want to use Plus POSIX and not the FreeRTOS APIs directly?

---

<div class="post-metadata">

**Author:** ![santhanraghava](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@santhanraghava](https://forums.freertos.org/u/santhanraghava)\
**Post date:** [January 7, 2023, 8:47pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/7 "2023-01-07T20:47:49Z")

</div>

These warnings are coming from FreeRTOS\_POSIX\_xxxx.c files which is having semphr.h file in includes. My project uses dynamic allocation, therefore configSUPPORT\_STATIC\_ALLOCATION = 0 . Because of this the static functions are disabled. But in pthread\_create function xSemaphoreCreateMutexStatic and xSemaphoreCreateBinaryStatic functions are used. Currently I have solved the warnings by changing the static functions (removing -static letters) and removing the buffer parameter argumets. Please let me know if my approach is right?

Regarding POSIX, I creating a system where it is RTOS interoperable. Therefore I want to use POSIX APIs in the application code.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [January 8, 2023, 8:10am UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/8 "2023-01-08T08:10:38Z")

</div>

> [@santhanraghava](#):
>
> Please let me know if my approach is right?

Yes, that should work.

> [@santhanraghava](#):
>
> Regarding POSIX, I creating a system where it is RTOS interoperable. Therefore I want to use POSIX APIs in the application code.

Be aware that FreeRTOS-Plus-POSIX is a labs project and it implements only a subset of the POSIX APIs. Do you plan to write one application and use it on 2 different RTOS currently? Or are you trying to ensure that you have an option to replace RTOS in future? The reason I am asking is because using the native APIs is more efficient in terms of memory and run-time. Therefore, if your use case is the latter one, you should evaluate the effort of porting your application to a different RTOS vs the overhead of using POSIX wrapper. In both the use cases, you need to ensure that you do not use any native FreeRTOS API in your application to keep it portable.

---

<div class="post-metadata">

**Author:** ![santhanraghava](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@santhanraghava](https://forums.freertos.org/u/santhanraghava)\
**Post date:** [January 8, 2023, 5:08pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/9 "2023-01-08T17:08:03Z")

</div>

I am trying to ensure that I have an option to replace the RTOS in future. I am aware of the fact that there will be overhead due to POSIX, but the project I am working is a research project and need not be efficient on computational level. My plan is to develop some simple application without any FreeRTOS APIs for the prototype.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [January 8, 2023, 5:40pm UTC](https://forums.freertos.org/t/problems-with-freertos-and-posix/11271/10 "2023-01-08T17:40:30Z")

</div>

POSIX seems to be the right choice for your use case then 🙂
