Quality RTOS & Embedded Software

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




Loading

xTaskResumeAll() not inside a task

Posted by microwavesafe on February 5, 2017

Is it safe to call xTaskResumeAll outside of a task? The reason I ask is I'm getting "strange" issues when I create a semaphore outside of task and because I'm using heap_3.c which just wraps malloc in vTaskSuspendAll and xTaskResumeAll, it is this call that causes the problems.

If I implement my own calls to malloc, it all works fine and if I just call vTaskSuspendAll it works (which I'd expect as this is just a counter increment). But as soon as I run xTaskResumeAll my USB CDC stops working, which I haven't been able to track the exact problem as a lot of it is library code built into the ROM, so I'm struggling to debug it.

The processor is LPC11U68 (cortex M0+).


xTaskResumeAll() not inside a task

Posted by microwavesafe on February 5, 2017

Actually I wasn't calling vTaskStartScheduler, instead I had a for loop to just test the USB CDC. As soon as I switched back to using vTaskStartScheduler all was well again. So even though vTaskResumeAll is still called before vTaskStartScheduler, as long as it's called my project functions.

If I don't call vTaskStartScheduler then it looks like I get memory corruption or something similar. Does this make sense?


xTaskResumeAll() not inside a task

Posted by rtel on February 5, 2017

Is it safe to call xTaskResumeAll outside of a task?

There is only one place the function can be called outside of a task, and that is before the scheduler is started. xTaskResumeAll() is called by some of the functions that create RTOS objects, so while I can't see any reason to call it directly before the scheduler has started (what is being resumed if no tasks are running?), it is commonly called indirectly (called by other API functions) before the scheduler starts.

It can't be called from an interrupt. Only functions that end if 'FromISR' can be called from an interrupt.

If I implement my own calls to malloc, it all works fine and if I just call vTaskSuspendAll it works (which I'd expect as this is just a counter increment). But as soon as I run xTaskResumeAll my USB CDC stops working, which I haven't been able to track the exact problem as a lot of it is library code built into the ROM, so I'm struggling to debug it.

Right. That is because calling API functions before the scheduler has been started will leave interrupts disabled. That is deliberate and to stop interrupt handlers trying to use the RTOS API before the scheduler has started (which in the early days was the cause of a LOT of support requests).


xTaskResumeAll() not inside a task

Posted by microwavesafe on February 5, 2017

xTaskResumeAll() not inside a task

Posted by microwavesafe on February 5, 2017

Yes I have some drivers that create sempahores before their tasks are created, which is called before the scheduler starts. Because I'm using heap_3.c this calls xTaskResumeAll for me, so I was calling it myself to being with.

Ah that's why, interrupts are left disabled. So I should be able to initialise the CDC inside a task and it all work correctly. Thanks for getting back to me. I kept replyinh below as it didn't refresh with this reply!


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS