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

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) 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