inflearn logo

FreeRTOS Programming 3 - Analyzing the Kernel Source, Reading It Line by Line and Verifying RTOS Internals on the Board

Have you ever wondered what the kernel actually does beneath a single line of `vTaskDelay` while using FreeRTOS? Follow `tasks.c` and `port.c` line by line, verify what happens using registers and memory on an STM32 board, and make the kernel’s inner workings—lists, context switching, the scheduler, queues, and memory management—your own.

4 learners are taking this course

Level Intermediate

Course period Unlimited

FreeRTOS
FreeRTOS
rtos
rtos
stm32
stm32
C
C
FreeRTOS
FreeRTOS
rtos
rtos
stm32
stm32
C
C

What you will gain after the course

  • How to read tasks.c, queue.c, and port.c line by line

  • How Cortex-M Context Switching (PendSV, SVC, SysTick) and BASEPRI Critical Sections Work

  • The process by which the scheduler selects the next task and wakes tasks on each tick.

  • Internal Structure and Differences Among Queues, Semaphores, Mutexes, Notifications, Event Groups, and Timers

  • heap_4, stack watermark, and how to read a board halted by configASSERT/HardFault

What you’ll gain by completing the course

You’ll be able to explain what FreeRTOS does on your board, citing specific source line numbers. When your board freezes or its timing goes off, you’ll find evidence in the source and memory instead of treating the kernel as a black box and guessing.

One-line summary

Starting with lists and TCBs, we work through context switching, the scheduler, ticks, critical sections, queues and synchronization, heaps and stacks, fault analysis, and multicore. We examine the FreeRTOS V10.3.1 kernel source and take measurements on an STM32F429I-DISC1 board. 39 chapters, about 6 hours and 55 minutes.

About the production process

This course was created using an AI-based production process. The narration uses synthetic speech trained on the instructor’s own voice, and AI tools were also used to create the script, graphics, and introduction video. The instructor personally handled the planning and content review, and all lab results were verified by running them on an actual STM32F429I-DISC1 board and in STM32CubeIDE.

Does vTaskDelay(1) really mean one millisecond?

Even if you’ve been using FreeRTOS for years, there are questions that are hard to answer: How long does vTaskDelay(1) actually wait? Why is there no source file for semaphores? Why does the call stack on a halted board point to vListInsert? API documentation tells you what something does, but not how it does it.

This course reads tasks.c, queue.c, and port.c, following the execution order and pointing out the line numbers as it goes. Then it verifies what you’ve read against the board’s memory, registers, and cycle counts. Understand the kernel through evidence, not guesswork.

You don’t read all 5,000 lines from the beginning

tasks.c alone is over 5,000 lines. Rather than following the order of the files, this course follows the order in which the kernel actually runs, progressing through three steps.

STEP 1

The kernel’s backbone

Lists, TCBs, and the initial stack

STEP 2

The heart of the kernel

Context switching, the scheduler, and ticks

STEP 3

Tools on top of the kernel

Locks, queues, memory, and reading faults

Why Kernel Source Code Now

With a single checkbox, STM32CubeMX adds FreeRTOS to your project. This has made it easier to use an RTOS, but it has also led to more cases of people using one without knowing what’s happening under the hood. How much stack to allocate, what interrupt priority to set, and why execution stopped at a particular point are all questions that can only be answered by understanding how the kernel works. As tools that write code for us become more common, developers who can explain why that code behaves the way it does become even more valuable.

What You'll Learn

The Kernel’s Skeleton and Heart

01 How to read tasks.c and the list structure

02 Dissecting the TCB: How to Know a Task’s State Without State Variables

03 Setting up the first stack and getting from main() to the first task

04 PendSV, SVC, and SysTick Context Switching and BASEPRI

05 Choosing tasks, ticks, and the two delay lists

Tools on Top of the Kernel and Reading Failures

06 Critical Sections, Scheduler Suspension, and Two Locks

07 Queue internals and xQueueGenericSend, line by line

08 Semaphores, mutexes, inheritance, notifications, events, and timers

09 heap_4, stack high-water marks, task deletion, and memory

10 Reading configASSERT and HardFault, CMSIS wrappers, and multicore support

18 years of hands-on teaching experience

Since 2008, I’ve taught developers at companies and institutions such as Samsung Electronics, LG Electronics, SK hynix, and Hyundai Mobis. The question I’ve heard most often on the job is, "So what exactly happens inside the kernel?" I designed this course to answer that question with a single line of source code and one number on the board.

For those who are comfortable with the API but curious about what lies beneath

If you’ve had no trouble creating tasks and using queues, but have had to rely on guesswork to figure out why the board freezes or timing goes awry, this course will replace that guesswork with evidence.

What makes this course unique

Read source code by line number

The screen shows the actual kernel source code with line numbers, while the lists and registers affected by each line change in sync beside it.

Verify it on the board

In each chapter, we load the practice build onto the board and read memory, registers, and cycle counts to verify what we saw in the source.

in execution order

Read in the order the kernel runs, not the order of the files.

Correcting Common Misconceptions

Each chapter covers common misconceptions and how to apply the material in practice.

Through V11 and multicore systems

We’ll also look at what changes under SMP, using V10.3.1 as the baseline.

Actual course screen

The two delayed lists that move together with line 2740 of tasks.c

The end-marker address of the list read directly from board memory

How long vTaskDelay(1) actually waits

How Many Kernels Are There with Two Cores? AMP and SMP

Where to Start Reading: Lines of Code in Each Kernel File

Why pxTopOfStack must be the first member of the TCB, line 247 in port.c

Setting up the initial stack for a task that has never run

Even with two context switch requests, PendSV runs only once

Line 911 of xQueueGenericSend: Three Locks Held at the Same Time

The event group waiting list read from the board

When Is Memory Reclaimed After Deleting a Task? The Two Paths of vTaskDelete

A configASSERT map for reading where execution stopped

Practice Environment

Basic Environment

  • STM32F429I-DISC1 board

  • STM32CubeIDE, STM32CubeMX

  • FreeRTOS V10.3.1 (CMSIS-RTOS v2, heap_4)

  • Practice project ZIP provided (just change the exercise number for each chapter and build)

Even without a board

  • All measurement results are shown in the video.

  • In the multicore chapter, we also read through the V11.1.0 source code.

Frequently Asked Questions

Q. Do I absolutely need a board?

No. The videos show both the source code and the results measured on the board. If you’d like to reproduce the measurements yourself, prepare an STM32F429I-DISC1 board, build the hands-on project provided in the course, and perform the same measurements.

Q. Do I need to take FreeRTOS Programming Parts 1 and 2 first?

It’s not required. Experience using FreeRTOS APIs such as tasks, queues, and semaphores is enough. If Part 2 is a course on fixing real-world bugs based on evidence, Part 3 is a course on reading the kernel source to understand what happens inside when those bugs occur.

Q. Can I follow along even if I don’t know the Cortex-M architecture well?

We explain everything you need for the course in the relevant chapters. If you want to dive deeper, each chapter points you to the ARM Architecture Reference Manual and Inflearn’s “ARM Cortex-M Processor Programming” course.

Q. Is the narration AI-generated?

Yes. It’s synthesized speech trained on the instructor’s own voice. The instructor personally planned and reviewed the script and hands-on exercises, and the exercise screens show results measured by running them on a real board.

Recommended for
these people

Who is this course right for?

  • A developer who has used the FreeRTOS API but is curious about the kernel’s internals

  • For those who want to trace RTOS issues at the source level

  • Students enrolled in FreeRTOS Programming 1 and 2

Need to know before starting?

  • C Language Pointers and Structures

  • Experience using the FreeRTOS API

  • STM32 Development Basics

Hello
This is guileschool

Career Verified

3,629

Learners

263

Reviews

281

Answers

4.7

Rating

9

Courses

I majored in electronic engineering at Inha University and worked as an embedded software developer.

I have been teaching in-person courses for 18 years since 2008. I taught developers at companies and institutions including Samsung Electronics, LG Electronics, SK hynix, Hyundai Mobis, LIG D&A, and Seoul National University, and compiled that experience into course materials.

『RTOS』(2008), 『Linux Shell』(2018), 『FreeRTOS』(2019), 『Cortex-M』(2022), 『Bootloader-Based Embedded Systems』(2023)

YouTube Giles School (https://www.youtube.com/@guileschool): Embedded Systems and Development Courses

I have also been researching Mac automation for 15 years. I teach ways to reduce repetitive tasks using Keyboard Maestro and AppleScript, and I develop and sell Greenlight, an automation plugin for Final Cut Pro. I publish the tools I create on GitHub (https://github.com/guileschool).

Captain Macbot on YouTube (https://www.youtube.com/@captainmacbot): How to use AI and automation on a Mac

Please send course requests and other inquiries to guileschool@gmail.com.

More

Curriculum

All

41 lectures ∙ (7hr 3min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

guileschool's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

Limited time deal

$122.10

34%

$187.00