{"id":406,"date":"2025-04-07T00:34:54","date_gmt":"2025-04-06T19:04:54","guid":{"rendered":"https:\/\/dctn.in\/?p=406"},"modified":"2025-04-09T00:44:26","modified_gmt":"2025-04-08T19:14:26","slug":"freertos_arch","status":"publish","type":"post","link":"https:\/\/dctn.in\/index.php\/blog\/freertos_arch\/","title":{"rendered":"Architecture of FreeRTOS: Inside the Engine of Embedded Systems"},"content":{"rendered":"\n<p class=\"has-cyan-bluish-gray-background-color has-background\"><strong>FreeRTOS<\/strong> is one of the most widely adopted real-time operating systems in the embedded world \u2014 and for good reason. It\u2019s tiny, fast, and built to run on microcontrollers with limited resources. But what makes it tick under the hood? Let\u2019s dive into the <strong>architecture of FreeRTOS<\/strong> and explore how it delivers real-time performance with simplicity and efficiency.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Core Design Philosophy<\/h3>\n\n\n\n<p class=\"has-pale-cyan-blue-background-color has-background\">At its heart, <strong>FreeRTOS is designed for simplicity, portability, and deterministic behavior<\/strong>. The architecture is modular, written in C, and built to be hardware-agnostic \u2014 with just a small layer of hardware-specific code (called the <strong>porting layer<\/strong>).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Key Components of FreeRTOS Architecture<\/h3>\n\n\n\n<div class=\"wp-block-group has-white-background-color has-background has-medium-font-size is-vertical is-content-justification-left is-nowrap is-layout-flex wp-container-core-group-is-layout-e95b0813 wp-block-group-is-layout-flex\">\n<h4 class=\"wp-block-heading\">1. <strong>Tasks (or Threads)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Tasks are the basic units of execution.<\/li>\n\n\n\n<li>Each task has its own <strong>stack<\/strong>, <strong>priority<\/strong>, and <strong>state<\/strong> (Running, Ready, Blocked, Suspended).<\/li>\n\n\n\n<li>Tasks can be created, deleted, suspended, or resumed dynamically.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>Scheduler<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>preemptive or cooperative scheduler<\/strong> is the brain of FreeRTOS.<\/li>\n\n\n\n<li>It decides which task runs next, based on <strong>priority<\/strong> and <strong>state<\/strong>.<\/li>\n\n\n\n<li>In preemptive mode, higher-priority tasks can interrupt lower-priority ones.<\/li>\n\n\n\n<li>In tickless mode, the scheduler conserves power by turning off the system tick timer when idle.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>Kernel Tick (SysTick)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A periodic interrupt (usually every 1ms) drives the scheduler.<\/li>\n\n\n\n<li>It updates task delays and triggers context switches.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. <strong>Queues<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>FreeRTOS provides <strong>message queues<\/strong> for safe inter-task communication.<\/li>\n\n\n\n<li>They help tasks exchange data without conflicts.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. <strong>Semaphores &amp; Mutexes<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used for <strong>synchronization<\/strong> and <strong>resource sharing<\/strong>.<\/li>\n\n\n\n<li><strong>Binary semaphores<\/strong> for signaling.<\/li>\n\n\n\n<li><strong>Counting semaphores<\/strong> for tracking events.<\/li>\n\n\n\n<li><strong>Mutexes<\/strong> with <strong>priority inheritance<\/strong> to prevent priority inversion.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. <strong>Timers<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Software timers allow you to run functions after a timeout or periodically, without creating a task for each.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">7. <strong>Memory Management<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Multiple allocation schemes are available:\n<ul class=\"wp-block-list\">\n<li><code>heap_1<\/code> (very basic, no freeing)<\/li>\n\n\n\n<li><code>heap_2<\/code> (alloc\/free without defragmentation)<\/li>\n\n\n\n<li><code>heap_4<\/code> (best balance \u2013 alloc\/free + coalescing)<\/li>\n\n\n\n<li><code>heap_5<\/code> (supports multiple memory regions)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">8. <strong>Porting Layer<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A thin hardware-specific layer that connects FreeRTOS to the underlying processor.<\/li>\n\n\n\n<li>Handles context switching, SysTick configuration, and interrupt priorities.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-alpha-channel-opacity has-vivid-red-background-color has-background is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">FreeRTOS Architecture Diagram<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"1024\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2025\/04\/arch_design-683x1024.png\" alt=\"\" class=\"wp-image-407\" style=\"width:334px;height:auto\" srcset=\"https:\/\/dctn.in\/wp-content\/uploads\/2025\/04\/arch_design-683x1024.png 683w, https:\/\/dctn.in\/wp-content\/uploads\/2025\/04\/arch_design-200x300.png 200w, https:\/\/dctn.in\/wp-content\/uploads\/2025\/04\/arch_design-768x1152.png 768w, https:\/\/dctn.in\/wp-content\/uploads\/2025\/04\/arch_design.png 1024w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-alpha-channel-opacity has-vivid-red-background-color has-background is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Flashed across all MCU <\/strong><\/h2>\n\n\n\n<p><strong>Lightweight<\/strong>: Minimal memory footprint.<\/p>\n\n\n\n<p><strong>Deterministic<\/strong>: Real-time deadlines are met.<\/p>\n\n\n\n<p><strong>Modular<\/strong>: Use only what you need.<\/p>\n\n\n\n<p><strong>Portable<\/strong>: Runs on over 40+ microcontroller architectures.<\/p>\n\n\n\n<p><strong>Reliable<\/strong>: Used in commercial-grade systems from automotive to IoT. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>read more about MCU and MPU<\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-next-gen-innovation-dctn wp-block-embed-next-gen-innovation-dctn\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"14y990Hy4k\"><a href=\"https:\/\/dctn.in\/index.php\/2025\/03\/31\/differences-between-microcontroller-and-microprocessor\/\">Differences Between Microcontroller and Microprocessor<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Differences Between Microcontroller and Microprocessor&#8221; &#8212; Next Gen Innovation | DCTN\" src=\"https:\/\/dctn.in\/index.php\/2025\/03\/31\/differences-between-microcontroller-and-microprocessor\/embed\/#?secret=v180F2xP21#?secret=14y990Hy4k\" data-secret=\"14y990Hy4k\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">Why do we prefer RTOS ? <\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Closing Remarks<\/h3>\n\n\n\n<p>FreeRTOS&#8217;s architecture used in ESP 32 chip <a href=\"https:\/\/www.espressif.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.espressif.com\/<\/a> might seem minimal at first glance \u2014 but that\u2019s its superpower. It delivers <strong>real-time performance<\/strong>, <strong>code portability<\/strong>, and <strong>flexibility<\/strong> without the complexity of traditional operating systems. Whether you&#8217;re building a smart sensor, a medical device, or an industrial controller, FreeRTOS provides a rock-solid foundation to bring your embedded ideas to life.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n","protected":false},"excerpt":{"rendered":"<p>FreeRTOS is one of the most widely adopted real-time operating systems in the embedded world \u2014 and for good reason. It\u2019s tiny, fast, and built to run on microcontrollers with limited resources. But what makes it tick under the hood? Let\u2019s dive into the architecture of FreeRTOS and explore how it delivers real-time performance with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[1],"tags":[39,38],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-blog","tag-architecture","tag-freertos"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":5,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}