How to set task priority in free rtos

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel Studio 7 

Device: ATmega32A
OS: Window 10

Free RTOS :10.3.0.

 

I have been looked in page https://www.freertos.org/a00129.html  I am trying to understand how to set task priority  in free rtos programming. I just assuming there are three tasks and each task print one message 

 

Task  - priority 

welcome - 2

hello     - 1

Mr. X    - 3 

 

I just want to understand which function call need to set priority of task's in free rtos 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely, this is entirely a FreeRTOS thing - nothing to do with AVR or Atmel Studio at all.

 

For FreeRTOS questions, you should be going to the FreeRTOS support forum

 

https://forums.freertos.org/

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Simplest solution is simply to give them all the same priority.

 

Priority is exactly what it says. It would say which task(s) have higher priority when it comes to deciding which should be run next. If they are all set the same then they should be given equal amounts of CPU time. Only if one is doing a " more important job" might you consider setting its priority higher than the others so it's more likely to get CPU time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Surely that is covered in the Free RTOS manual?

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

More than that - it is clearly stated on the very page that the OP linked!!

 

frown

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Simplest solution is simply to give them all the same priority.

 

Priority is exactly what it says. It would say which task(s) have higher priority when it comes to deciding which should be run next. If they are all set the same then they should be given equal amounts of CPU time. Only if one is doing a " more important job" might you consider setting its priority higher than the others so it's more likely to get CPU time.

Yes i know it, I think you have worked with rtos,  I want to find out which function should call back to set task priority. I do not understand even looking other source code. My attempt was that I had to find out which function should be called for task priority and task secreting. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rahulk7 wrote:
I want to find out which function should call back to set task priority. I do not understand even looking other source code. My attempt was that I had to find out which function should be called for task priority and task secreting. 

Is this a school project?

Have each task call this function with the appropriate value added, i.e. change the 1 to what priority each task wants. 

vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Thu. Apr 16, 2020 - 02:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

rahulk7 wrote:
I want to find out which function should call back to set task priority.

Go on - it tells you exactly that right on the page you linked in your opening post!

In #1, you wrote:
I have been looked in page https://www.freertos.org/a00129.html 

Here is that very page:

 

 

What more do you need?

 

It even gives you an example!

 

And, again, why are you posting here? It has nothing to do with AVR or Microchip or Atmel Studio!

 

FreeRTOS has its very own forum dedicated specifically to FreeRTOS:

 

https://forums.freertos.org/

 

that is the place to get FreeRTOS help!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Apr 16, 2020 - 02:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why bother with priority at all if you don't understand the concept? The fact is that all tasks must be created with some default priority anyway so just accept that, whatever it is.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you propose to use relative task priorities, make sure to read up on how the FreeRTOS task scheduler works. It's very easy for a high-priority task to hog the CPU and starve lower-priority tasks unless it yields, blocks or you otherwise introduce synchronisation points.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

obdevel wrote:
It's very easy for a high-priority task to hog the CPU and starve lower-priority tasks unless it yields,

True for any RTOS that I'm aware of.

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"