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:
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.