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] [August 2012 Threads] Order of thread execution?Posted by kuku2010 on August 27, 2012 3 threads: A @ priority 3, B @2, C @1, one interrupt D, system tick is 1ms
All threads takes only a small fraction of time to run most time.
A ran for a fraction of ms and wait for the semaphore to be given by D, so the next thread will run B ran for a fraction of ms and use vTaskDelay(1) to allow the next thread to run C ran for a fraction of ms and called vTaskDelay(1)
At this point, 1ms hasn't passed yet, so will the system enter some idle state until the next tick? If so, is there a way to wake up a specific thread? For example, wake up B and it runs until the next tick, which will be A's turn again.
(Still no system tick) If D gives the semaphore, will A resume immediately? If so, when the next system tick occurs, I assume A continue since it has the highest priority
Thanks for your time!
RE: Order of thread execution?Posted by Dave on August 27, 2012 “At this point, 1ms hasn't passed yet, so will the system enter some idle state until the next tick?” The idle task will run at priority 0. “For example, wake up B and it runs until the next tick, which will be A's turn again.” Your code has told B to wait for 1 tick, so that is what it will do. You could run B at priority 0 too, in which case it will share processing with the idle task when A and C are not running. Setting configIDLE_SHOULD_YIELD to 1 in FreeRTOSConfig.h makes the idle task always yield to B straight away if B is not blocked. Alternatively you can make B block on a semaphore instead of vTaskDelay(1) and give the semaphore from the idle hook function but that would seem like overkill. “If D gives the semaphore, will A resume immediately?” Yes, if that is what you told it to do, of course. The port you are using will have a YIELD_FROM_ISR or END_SWITCHING_ISR macro to ensure it happens. Both macros do the same thing, different ports just use different names for some reason. Look at the examples that come with your port. http://www.freertos.org/a00090.html “If so, when the next system tick occurs, I assume A continue since it has the highest priority” Yes. The highest priority task that is not blocked or suspended will always run, and time slice with other tasks that have the same priority and are also not blocked if there are any.
RE: Order of thread execution?Posted by kuku2010 on August 28, 2012 "Setting configIDLE_SHOULD_YIELD to 1 ", do you mean "Setting configIDLE_SHOULD_YIELD to 2", since B has priority of 2?
RE: Order of thread execution?Posted by Dave on August 28, 2012 “Setting configIDLE_SHOULD_YIELD to 1 ", do you mean "Setting configIDLE_SHOULD_YIELD to 2", since B has priority of 2” No, configIDLE_SHOULD_YIELD is binary, 1 or 0. I mentioned it in context of running the other task at priority 0 (idle priority). Look it up on http://www.freertos.org/a00110.html
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|