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] [March 2009 Threads] Diagnostics_TASK_SWITCHED_IN and _OUTPosted by Eduardo Goncalves on March 24, 2009 Hi :)
I've created a diagnostics module that pretends to measure the amount of time that each task runs per second.
Therefore I'm using the macros: Diagnostics_TASK_SWITCHED_IN Diagnostics_TASK_SWITCHED_OUT
This is the code of the ..._IN macro (the ..._OUT is very similar):
void Diagnostics_TASK_SWITCHED_IN ( pdTASK_HOOK_CODE pxTaskTag ) { uint16 TickCount;
TickCount = xTaskGetTickCount();
...
when I use the code like this the system ends up in the __prefetch_handler, with very starnge values in the LR register.
If a comment the call to xTaskGetTickCount then all goes fine.
I've examined the function xTaskGetTickCount and it seems quite harmless. I've tried to step into xTaskGetTickCount but it does not crash on the first 10 calls or so, it takes longer.
would there be any reason for this?
thanks
RE: Diagnostics_TASK_SWITCHED_IN and _OUTPosted by Samuel Tardieu on March 24, 2009 Eduardo,
I'm not answering your question but just raising a warning about your methodology: do not forget that xTaskGetTickCount() will only return a number of ticks, with the granularity of the system ticks. If you run at 1000Hz (which is I believe the case for most if not all demos, see configTICK_RATE_HZ), then your precision is only that.
If a task records 1 tick with your counting method, it may well have executed only for a few nanoseconds and crossed a system tick increment. Similarily, a task may have executed for 999 microseconds and record 0 tick because it was all contained between two system ticks.
If these situations do repeat during the lifecycle of your application, you may end up with Task1 having apparently consumed all the time and Task2 having consumed none while in fact Task2 used 99% of CPU time and Task1 0,001%.
Because of that, I would suggest to use a system timer which will record the amount of time spent in each task much more accurately, especially if you intend to use rate-monotonic-scheduling to determine a set of static priorities for your task.
RE: Diagnostics_TASK_SWITCHED_IN and _OUTPosted by Dave on March 24, 2009 I presume this is being called form the tick in which case you cannot use xTaskGetTickCount() because is uses a critical section. Create a version without a critical section or just read the tick count variable directly.
RE: Diagnostics_TASK_SWITCHED_IN and _OUTPosted by Eduardo Goncalves on March 24, 2009 Two very good points :)
I'll try to use a timer!
thanks
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|