use of same byte pool from more than one thread in threadX
Hi!
i have a question about the use of byte pool in threadX.
in the App_ThreadX_Init(VOID *memory_ptr) i have the pointer to the byte pool is given like that:
UINT App_ThreadX_Init(VOID *memory_ptr)
{
UINT ret = TX_SUCCESS;
TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr;
and i'm using this pointer to allocate memory for thread, queue ecc .
now i'm passing the pointer byte_pool to my threads like this:
tx_byte_allocate(byte_pool,&pointer,CONSOLETHREAD_STACK_SIZE, TX_NO_WAIT);
tx_thread_create(&threadConsole,"console_thread",console_thread_entry,(ULONG)byte_pool,pointer,CONSOLETHREAD_STACK_SIZE,15,15,1,TX_AUTO_START);and i want to use that pointer to allocate memory with tx_byte_allocate for sending via queue pointer to data structure instead of the actual data
example:
VOID *pointer;
if(tx_byte_allocate(byte_pool,&pointer,(sizeof(paramRequest_t)), TX_NO_WAIT) == TX_SUCCESS)
{
((paramRequest_t*)pointer)->startParamN = 0;
((paramRequest_t*)pointer)->quantity = paramsNum;
((paramRequest_t*)pointer)->readQueue_ptr = ¶msRequestINmodbusqueue;
if(tx_queue_send(¶msRequestqueue,&pointer, TX_NO_WAIT) == TX_SUCCESS)
{
requestParam = FALSE;
}
}in another thread when i receive the queue i free the memory
if(tx_queue_receive(¶msRequestqueue,¶mRequest,TX_NO_WAIT) == TX_SUCCESS) // read params request
{tx_byte_release(paramRequest);
the problem is that if i use the same byte_pool for all the thread it crash, if i use separate byte pool work normally
i have tried with a mutex when i use the allocate and free function but not seem to work..
is it possible to use the same byte pool or i must use separate byte pool for each thread?
thanks
