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

vTaskSuspendAll() is causing assert in queue.c

Posted by lantczak on April 7, 2015

Hi,

I found following problem.

The vTaskSuspendAll() suspends scheduler. It is called in many places in internal freeRtos files (e.g. queue.c, task.c, heap_4.c)

The problem is that if scheduler is suspended and the IRQ occur and inside this IRQ I call some API from freertos (e.g. xSemaphoreGiveFromISR or xQueueSendFromISR) then this call is triggering following assert:

            #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 )

)

            {

                            configASSERT( !( ( xTaskGetSchedulerState() ==

taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );

            }

File queue.c function xQueueGenericSend.

Simple test:

xSemaphoreHandle transmissionEnd;

transmissionEnd = xSemaphoreCreateBinary ();

UTILS_ASSERT (NULL != transmissionEnd);



vTaskSuspendAll();

xSemaphoreGiveFromISR (transmissionEnd, NULL); => this will trigger assert

I'm using v8.0.0 but I suspect that it is also in the newest version

Any ideas ?


Best regards

Ɓukasz Antczak


vTaskSuspendAll() is causing assert in queue.c

Posted by rtel on April 7, 2015

I just searched the source files (V8.2.1, not V8.0.0 admittedly) and can find four occurrences of:

configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );

Two are in event_groups.c, so I have not looked at those. Two are in queue.c.

One of the two in queue.c is in xQueueGenericReceive(), and the other is in xQueueGenericSend() - but neither of those functions should get called in an ISR. xSemaphoreGiveFromISR() calls xQueueGiveFromISR() (or probably xQueueSendFromISR() in your version).

So I don't know why you would hit those asserts - other than to say it looks like a non-ISR safe function is being called from an ISR.

I would recommend stopping on the debugger when the assert has been hit and looking at the call stack to see the sequence of function calls that took you to the assert.

Regards.


vTaskSuspendAll() is causing assert in queue.c

Posted by lantczak on April 7, 2015

Yes you are right. Thank you

From: Real Time Engineers ltd. [mailto:rtel@users.sf.net] Sent: Tuesday, April 7, 2015 9:54 PM To: [freertos:discussion] Subject: [freertos:discussion] vTaskSuspendAll() is causing assert in queue.c

I just searched the source files (V8.2.1, not V8.0.0 admittedly) and can find four occurrences of:

configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );

Two are in event_groups.c, so I have not looked at those. Two are in queue.c.

One of the two in queue.c is in xQueueGenericReceive(), and the other is in xQueueGenericSend() - but neither of those functions should get called in an ISR. xSemaphoreGiveFromISR() calls xQueueGiveFromISR() (or probably xQueueSendFromISR() in your version).

So I don't know why you would hit those asserts - other than to say it looks like a non-ISR safe function is being called from an ISR.

I would recommend stopping on the debugger when the assert has been hit and looking at the call stack to see the sequence of function calls that took you to the assert.

Regards.


vTaskSuspendAll() is causing assert in queue.c https://sourceforge.net/p/freertos/discussion/382005/thread/78e52fdf/?limit=25#6164


Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/ https://sourceforge.net/p/freertos/discussion/382005

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions

Attachments

alternate (4776 bytes)


[ 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