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


Knowing Scheduler Status

Posted by Nobody/Anonymous on February 21, 2007
Initializing and using LCD requires a lot of software delays, this is inefficient. Better way is to replace every SoftwareDelay() with vTaskDelay(t) or vTaskDelayUntil(t).

However vTaskDelay() can only be used when the scheduler is running.

I want to write a function Delay() such that, when it's called when scheduler is not running, it uses software delay, otherwise it uses vTaskDelay().

If [scheduler is NOT running]

How can I know scheduler is running or not? The variable "xSchedulerRunning" is declared in task.c, so not accessible. Should I take xSchedulerRunning out and declare in task.h, or is there a cleaner way?

Thank you.

RE: Knowing Scheduler Status

Posted by Nobody/Anonymous on February 21, 2007
A couple suggestions:

1) Rather than make the variable global, include an access function in tasks.c such as xIsSchedulerRunning() that returns the variable. This is a bit neater.

2) Most ports use a variable called ulCriticalNesting that is initialized to non zero, then set to zero when the first task starts. It is not static so can be accessed from any file, but be careful as it will still be non zero from within a critical section even when the scheduler is running.


RE: Knowing Scheduler Status

Posted by Nobody/Anonymous on February 21, 2007
It is a fairly safe bet that if uxCriticalNesting (ulCriticalNesting?) is > 15 then the scheduler has not been started unless you are writing really screwy code.

RE: Knowing Scheduler Status

Posted by Nobody/Anonymous on February 27, 2007
Thx.. i tried the first suggestion, it works.. , and clean code too..

I didnt try the second suggestion because I just dont understand what ulCriticalNesting does. Thank you anyway

[ 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