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

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