Quality RTOS & Embedded Software

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


Loading

xTaskGetTickCount in tasks.c/h

Posted by mike on December 11, 2007
Hello all

I am using a at91sam7s arm7 chip, with IAR toolchain and 4.5.0 freeRTOS.

I notice in definition of xTaskGetTickCount that the rturn of the count is surrouded by taskENTER_CRITICAL/taskEXIT_CRITICAL with the comment
/* Critical section required if running on a 16 bit processor. */

Presumably since the ARM is 32 bits, I can replace this with a simple return xTickCount? Can I 'automate' this by using the #if (sizeof(portBASE_TYPE) >= 4) or is this likely to fail somewhere else?

Hmm I find that IAR won't accept sizeof as a preprocessor command! Keep looking!

Many thanks in advance

Mike Newsome

Hitek Power Ltd, England

RE: xTaskGetTickCount in tasks.c/h

Posted by Richard on December 11, 2007
If the definition of portTickType is the natural size of the processor word size (portTickType == portBASE_TYPE in effect), then the enter/exit critical is not required. Removing the enter/exit critical also allows the function to be called from an ISR. You could of coarse just set the tick count variable to be global, if you don't mind doing that sort of thing.

Regards.

RE: xTaskGetTickCount in tasks.c/h

Posted by mike on December 11, 2007
I prefer to keep other fingers out of this, by hiding it, but resent the time taked to post the critical flags if not necessary!

Presumably the same applies to prvIsQueueEmpty, uxQueueMessagesWaiting and uxTaskGetNumberOfTasks, and also possibly prvIsQueueFull() as pxQueue->uxLength is set when the queue is set up, and cannot be dynamically changed.

Many thanks for your time and help

Mike

RE: xTaskGetTickCount in tasks.c/h

Posted by Richard on December 11, 2007
Be careful with the queue functions. prvIsQueueEmpty() and prvIsQueueFull() make a comparison, which is not atomic, so could require the critical section even though the comparison is with a constant - this depends on the code generated, it also depends on whether getting a result which for an instant is out of date really matters (which it probably doesn't). uxQueueMessagesWaiting(), uxTaskGetNumberOfTasks() should be ok.

Regards.

RE: xTaskGetTickCount in tasks.c/h

Posted by mike on December 11, 2007
Hi

Both prvIsQueueEmpty() and prvIsQueueFull() read the structure once then perform the compare on the values in registers and sort out the return value.

So should be OK (until the compiler optimizer changes anyway!) Perhaps I'll leave this one.

Regards


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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