FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [December 2007 Threads] xTaskGetTickCount in tasks.c/hPosted 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/hPosted 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/hPosted 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/hPosted 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/hPosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|