Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS multithreading issue

Posted by krishnaks on December 16, 2014

Hi All,

We are running multithreaded FreeRTOS application on 88MC200 Microcontroller.

  1. We have created a interrupt service routines for handling a GPIO pin interrupt and sending Gpio change status into a queue from interrupt service task using “xQueueSendToBackFromISR”.

  2. We have created 2 threads, One of the thread(Thread1) continuously receives the data from the message queue(GPIO change status sent from ISR()) using "xQueueReceive” and saves into the local buffer.

  3. In another thread(Thread2) we have implemented TCP socket server which accepts the connection from remote PC application and performs the socket send and recv operation continuously.

  4. Now the problem is, we are seeing that board hangs after some time ( 10-20 minutes of application start) and board is getting restarted after a while(No error message is displayed).During this scenario, We are receiving interrupts and Interrupt service routine fills the queue and becomes full but our thread is not able to receive(Looks like thread1 is not in active state). At this point, remote client application is also not getting the response from server which implies that thread2 is also not responding.

Can anyone explain why threads are not responding and is there any way to debug?

Thanks in advance,

Krishna


FreeRTOS multithreading issue

Posted by rtel on December 17, 2014

[sorry for the late reply, for some reason your post went into moderation, which it should not have done]

Most likely cause is an incorrect interrupt priority.

Which version of FreeRTOS are you using? As if it is a recent version then defining configASSERT() will catch most such issues. Do you have configASSERT() defined?

Are you using our own TCP/IP stack, or a different one?

Not related to your question - but depending on the frequency of the interrupt you may be better using a circular buffer rather than a queue to send data from the interrupt. The TCP/IP stack (link above) has a stream buffer implementation which some people are already using for this purpose - the link being such a discussion.

Regards.


FreeRTOS multithreading issue

Posted by krishnaks on December 18, 2014

Hi,

Thanks for the reply.

Using circular buffer implementation instead of queue, I am not facing board hang issue. Thanks for the suggestion. But not sure about Why I was facing board hang issue with queue usage.

Now when I am trying to create one more task (Already 2 tasks we crated), I am getting errCOULDNOTALLOCATEREQUIREDMEMORY error.

For first two taks, I have defined a stack of 3Kb and 1 Kb respectively. When I try to create a another task with 2 Kb stack I am facing memory problem.

If I am reducing the stack for 1 st thread to 2 KB, 3rd thread will run. But TCP server implemented thread in first thread will continuously throw accept error when client application trying to connect.

Board have 384 KB RAM and 1 MB flash embedded in it.

How I can overcome this memory issue?

Thanks in advance, Krishna


FreeRTOS multithreading issue

Posted by krishnaks on December 18, 2014

Hi,

Adding few things to my previous post. I am using heap4.c and available heap space is set to 72kb in FreeRTOSConfig.h using configTOTALHEAP_SIZE macro

Should I try heap_2.c?

Regards, Krishna


FreeRTOS multithreading issue

Posted by rtel on December 20, 2014

You have not said which TCP/IP stack you are using.

If you have 72K available, and have used up 4K in stacks, then something else must have consumed a lot of heap if you cannot then allocate another task. Do you know what that is? If not, find out by placing a break point in pvPortMalloc() to see what it is - or use FreeRTOS+Trace to log memory allocations.

Note stack sizes are defined in words, not bytes, so asking for a stack of 1000 on a 32-bit machine will result in a stack of 4000 bytes.

Regards.


FreeRTOS multithreading issue

Posted by rtel on December 20, 2014

By the way - our reply was late again because your post went into moderation again. Do you know why that might be?

Regards.


FreeRTOS multithreading issue

Posted by krishnaks on December 22, 2014

Hi,

I have no idea why my all posts are going to moderation.

I am using custom TCP/IP stack provided by WiFi vender. We are using additional 12 tasks for driver interfaces and all together 38K stacks allocated for all threads. If I am commenting any one of existing task, my application task will run.

Currently I am checking the places where and all used pvPortMalloc and eliminating the use of heap by declaring fixed array wherever possible.

Regards, Krishna


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists