- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
There's some part of the code I'm dealing with that needs the mutex to be initialized statically:
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
Is there any way to recreate such thing on WICED platform?
I have included wiced_rtos.h to have access to the wiced_mutex_t definition and added appropriate typedef:
typedef wiced_mutex_t pthread_mutex_t;
Header inclusion and typedef work fine, but static mutex initialization gives the error about undeclared PTHREAD_MUTEX_INITIALIZER.
Thanks in advance for the response!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The macro PTHREAD_MUTEX_INITIALIZER is used to initialize the mutex in a POSIX compatible system. In WICED, we have ThreadX and FreeRTOS Operating system. These RTOS do not have POSIX wrappers to determine the value of PTHREAD_MUTEX_INITIALIZER. You could include the POSIX wrappers for FreeRTOS in WICED and give it a try.
FYI: This link will be helpful FreeRTOS+POSIX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please tell what the value of PTHREAD_MUTEX_INITIALIZER is and where is it initialized?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I think its value is platform-dependent like in one case it can be initialized to some predefined value, like 0xFFFFFFFF, in another case it is a macro that is resolved to some kind of structure initialization values. And as a consequence, it isn't initialized anywhere, instead, it is an initializer by itself.
I'm wondering if there's such thing on WICED platform in general.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The macro PTHREAD_MUTEX_INITIALIZER is used to initialize the mutex in a POSIX compatible system. In WICED, we have ThreadX and FreeRTOS Operating system. These RTOS do not have POSIX wrappers to determine the value of PTHREAD_MUTEX_INITIALIZER. You could include the POSIX wrappers for FreeRTOS in WICED and give it a try.
FYI: This link will be helpful FreeRTOS+POSIX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, riya!
Thanks for the link, will check and give it a try.