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 xTaskStartScheduler

Posted by jirachi2 on May 16, 2014

I have a question. If I create a task with xTaskCreate(), and then start the scheduler with xTaskStartScheduler(), can I later on add new tasks? I think I can't because I have to set the priority in xTaskCreate.. and then it would mess up the priority of others maybe?

So If I cant, I have to create ALL tasks before I start the scheduler?

And can I later on delete tasks while the scheduler is running?


FreeRTOS xTaskStartScheduler

Posted by rtel on May 16, 2014

You can create tasks before or after the scheduler has been started.

You can delete tasks after the scheduler has been started.

The following rather old (and interestingly still using version 7.x types in places) standard demo does nothing but create and delete tasks while the scheduler is running: https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/Common/Minimal/death.c

Note if you delete tasks you must allow the idle task to run occasionally as it performs some clean up.

Regards.


FreeRTOS xTaskStartScheduler

Posted by jirachi2 on May 16, 2014

Thanks! If I create a task with xTaskCreate() after the scheduler has started, does the new task automatically run? Don't I have to call startScheduler() again or something alike?


FreeRTOS xTaskStartScheduler

Posted by rtel on May 16, 2014

vTaskStartScheduler() should only ever be called once. Any tasks created after the scheduler has started will automatically be added to the pool of tasks that are available to the scheduler, and will in fact run immediately if the task being created is given a priority that is higher than the task that created it.

Look at the example in the link already posted above.

Regards.


FreeRTOS xTaskStartScheduler

Posted by jirachi2 on May 16, 2014

Thanks. Least number is least priority? Highest number is highest priority? Or the other way around? ( i guess least is least priority, because often you don't know how many threads in the future are created))


FreeRTOS xTaskStartScheduler

Posted by rtel on May 16, 2014

Answers to all the questions you have asked so far can be found in the online docs.

http://www.freertos.org/RTOS-task-priority.html

Regards.


FreeRTOS xTaskStartScheduler

Posted by jirachi2 on May 16, 2014

I have another question.

For example, I have 1 class called Menu.cpp. The header looks like: - Menu() - void foo()

In the contrustor I create 1 task. This task just does random code (it doesn't matter). Then in the constructor, after the task is created, I call vTaskStartScheduler().

The Main looks like: { Menu menu; menu.foo(); }

Will the code get to menu.foo(); ? I don't know, because I read somewhere the code does not go past vTaskStartScheduler() unless there is a fatal error.


FreeRTOS xTaskStartScheduler

Posted by davedoors on May 16, 2014

http://www.freertos.org/a00132.html


[ 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