Introduction to RTOS Part 3 - Task Scheduling | Digi-Key Electronics

preview_player
Показать описание
The RTOS scheduler decides which task to run on a recurring basis, and some tasks can interrupt and run before other tasks in a process known as “preemption.”

CORRECTION at 2:37: A higher priority task in FreeRTOS will immediately preempt other tasks and run if it is made ready. It does not wait for the next tick to run. Thanks to @G-aurav B-hattarai for pointing this out!

In this video, we examine how the FreeRTOS scheduler makes a decision at every tick (recurring timer interval) to determine which task to run for the remainder of the tick. With a single-core processor, this time-slicing allows tasks to run in a fashion that appears to be concurrent to the user.

Tasks with higher priority are chosen to run before tasks with lower priority. However, not all tasks need to be run. Only tasks in the “ready” or are already in the “running” state can be chosen to run next. A task may put itself or another task in a “blocked” state by using one of the appropriate blocking functions, like vTaskDelay(). Tasks that are waiting for an external event, such as a free semaphore or a serial transmission, may also enter the blocked state. The expiration of a timer or received resource may move a task from the “blocked” state to the “ready” state.

Additionally, a task may put another task into the “suspended” state with the vTaskSuspend() function. This prevents the suspended task from running until another task calls the vTaskResume() function on the suspended task.

Note that tasks with equal priority are executed in a round-robin fashion.

Product Links:

Related Videos:

Related Project Links:

Related Articles:

Learn more:

Рекомендации по теме
Комментарии
Автор

Seriously great content here. Give this guy a raise. Well earned.

lagcisco
Автор

I think it is probably going to be one of the best FreeRTOS tutorials or maybe even the best.

Xsses
Автор

Thanks for doing this series in chunks.
I will have to let my brain process this episode and the prior episode in an equal priority round robin manner for a while until it is pre-empted by the higher priority episode 4 :)

qcnck
Автор

Small bug in your solution. You need to increment idx in line 75, otherwise, it only accepts the last digit...

claytube
Автор

This is definitely the best FreeRTOS tutorial

mitchellscales
Автор

Very good stuff, just in time for my FreeRTOS explorations. Please don't stop these video series halfway! :)

renaulth
Автор

this makes my life easier, since the freeRTOS doc is not for everyone.

mrlajel
Автор

Unbelievably ! you explained all of that in details in 10min ! Thank you so much for that great work and explaination.

elenobia
Автор

I can't thank you enough for these super useful contents.

AlwinArrasyid
Автор

Great course! Was looking for a next video, but it is super fresh. Looking forward to next ones.

andriisemenov
Автор

I tried the exercise using switch case, thanks Shawn for such amazing course!

pratikphadte
Автор

Shawn is just amazing on teaching so much simple and clear! Congrats!

pedrosena
Автор

IIRC, serial output may also cause a task to be not ready because it can take a tick to wait for the character to be output.

In an RT application, the serial output should be in a task dedicated for the output to that physical device port. Messages are then sent to that task when output is required. That strategy avoids garbled output produced by two or more tasks outputting to the same physical device. The serial output task can wait on a message in a queue so no cycles are burned by it unless there is something to do.

Similarly, some input operations duch as analog input or serial input may block.

Rule of thumb is one task per physical resource. With ADC, there is usually only one converter that has its input multiplexed over several ports. So one task per converter. If you know the hardware well, then you can start the conversion and suspend the task until the conversion is complete, resuming via ISR.

Scheduler may be configured to yield to the next ready task for the remainder of the tick when a task is suspended.

BerndFelsche
Автор

Great work! Really happy for this series. Thank you!

joaoagricio
Автор

1:02 preemptive scheduling
4:30 task states
7:00 vTaskSuspend() and vTaskResume() example

mohamedhassanin
Автор

Thank You So Much for This Amazing Video
Video Lecture - 3 Completed

PrithaMajumder
Автор

For the solution code, why the serial port only recieve the last number? If I send "123", serial port respond "Updated LED delay to: 3
".

mhwh
Автор

Great series. Looking forward to the next parts

MindOfIsaac
Автор

Beautiful video, very helpful to understand the fondamental concepts of RTOS. Thank you ❤️

antoniopellegrini
Автор

Hi! Great content. Thank you so much for producing these and making them available.

Just a minor correction: on the LED control exercise solution, there's a missing increment 'i++" operator in the buf_len index.

miguelfaf