- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
I write this code.
#include "wiced.h"
static wiced_thread_t xt;
static void x(uint args);
static void x(uint args)
{
WPRINT_APP_INFO( ("[x] running\n") );
}
void application_start(void)
{
UINT status;
/* Initializes the WICED system */
wiced_init ( );
for(int m = 0;m<10;m++)
{
WPRINT_APP_INFO( ("\nCreate thread #%d ...\n", m) );
status = wiced_rtos_create_thread ( &xt, WICED_APPLICATION_PRIORITY, "x", (wiced_thread_function_t)&x, 1024, NULL );
if ( status != WICED_SUCCESS )
{
WPRINT_APP_INFO( ("wiced_rtos_create_thread 'x' failed, status = %d\n", status) );
}
wiced_rtos_delay_milliseconds ( 1000 );
}
}
The first iteration of the "for" cycle creates thread successfully.
The subsequents iterations returns "wiced_rtos_create_thread 'x' failed, status = 1031"
1031 is THREAD_CREATE_FAILED.
I dont' understand ... I believe that in 1 seconds the 'x' thread finished because it has only to PRINT a simple string, so duration is less than 1 seconds. So I believe that ThreadX can create new thread with the same "static wiced_thread_t xt;".
Solved! Go to Solution.
- Labels:
-
WICED Studio Wi-Fi Combo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In addition to my previous response, in your demo application, you have declared static wiced_thread_t xt, and you're passing this same variable for all the threads that you're creating in the for loop. If you go through the arguements of the API "wiced_rtos_create_thread", you'll see that the first variable "wiced_thread_t* thread", it is a pointer to the variable that will receive the thread handle. You can't provide the thread handle of different threads you're creating to that same variable. Instead, you should declare something like this -->
static wiced_thread_t xt[10];
I have attached my code example and it's running fine. Let me know if you face issues.
Thanks
Aditi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I see that in the API "wiced_rtos_create_thread", the fourth arguement that you have passed is address of your function i.e. 'x', instead the API demands the function name of the function instead of the address. Correct me, if I am wrong but the API should be
wiced_rtos_create_thread ( &xt, WICED_APPLICATION_PRIORITY, "x", (wiced_thread_function_t)x, 1024, NULL );
Can you do this change and check again?
Thanks
Aditi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In addition to my previous response, in your demo application, you have declared static wiced_thread_t xt, and you're passing this same variable for all the threads that you're creating in the for loop. If you go through the arguements of the API "wiced_rtos_create_thread", you'll see that the first variable "wiced_thread_t* thread", it is a pointer to the variable that will receive the thread handle. You can't provide the thread handle of different threads you're creating to that same variable. Instead, you should declare something like this -->
static wiced_thread_t xt[10];
I have attached my code example and it's running fine. Let me know if you face issues.
Thanks
Aditi