Quality RTOS & Embedded Software

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


Loading

Knowing Scheduler Status

Posted by Nobody/Anonymous on February 21, 2007
Hi,
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]
Delay(1000000);
else
vTaskDelay(300);

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.

Dave.

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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner