Quality RTOS & Embedded Software

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




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