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 2014 Threads]
Hi, I'm new for RTOS. I got some very basic Questions for FreeRTOS:
1.I got 2 tasks, A need run 10ms a loop and B need 100ms per loop. they got same priority, how the system will run this 2 tasks? Did it run A 10ms then B 100ms a loop or run A 10ms then B 10ms?
2.Same as 1. but A is higher priority than B, how the system go?
3.still A and B same priority if i want to run each task 5ms then switch to another task 5ms as a loop what should i did?
The system will run the highest task that is available to run, and when that task blocks the system will switch to the next task (that is now the highest ready to run). If two tasks are the same priority, then FreeRTOS will switch between them (if you allow preemption) every timer tick, or on a call to vTaskYield.
You talk about a task running x ms "a loop", if by that you mean that it computes for x ms to get a result, and then would naturally immediately start a new computation again (without blocking), THIS IS BAD. Such a task will monopolize the system and any tasks of lower priority will never run.
Tasks of this sort really, if you really need them, should only exist at the idle priority, so there can be no tasks of lower priority, and then let freeRTOS switch between them with preemption, or have Yields in the loop.
Generally, tasks "do their thing" in response to something, be it a semaphore being set or data being put in a queue, either from another task or an interrupt. Sometime it might just be on a periodic basis based on timer ticks, and the task will block when done waiting for the conditions to arise when it should do its thing again.
Here are a few links in addition to Richard's answer:
vTaskDelayUntil() - used for creating periodic tasks:
http://www.freertos.org/vtaskdelayuntil.html
configUSETIMERSLICING:
http://www.freertos.org/a00110.html#configUSETIMESLICING
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.