UI はローカライズ済みです。スキルの紹介と説明文書は選択した言語へ AI が自動翻訳し、コード・コマンド・パス・専門用語は原文のままです。原作者の文書が優先されます。
スキルを探す
生産性・共同作業 · SKILL.md

rtos

rtos

RTOS Internals

Independent GitHub snapshot · Automated classification · Original documentation governs

スキルの説明

GitHub

name: rtos description: RTOS Internals

Real-Time Operating Systems (RTOS) Mechanics

Preemptive Scheduling and FreeRTOS Internals

FreeRTOS utilizes a priority-based, preemptive scheduling algorithm. The core data structure is pxReadyTasksLists, an array of List_t structures, one for each priority level up to configMAX_PRIORITIES - 1. The scheduler always selects the highest priority task in the ready state. Context switching is architecture-specific but fundamentally involves saving the CPU context onto the task's stack, updating the TCB (Task Control Block) stack pointer, and restoring the context of the newly selected task via a PendSV handler in ARM Cortex-M architectures.

Priority Inheritance in Mutexes

To prevent priority inversion, FreeRTOS implements priority inheritance for its Mutex objects (which are specialized semaphores). When a high-priority task attempts to acquire a Mutex held by a lower-priority task, the scheduler temporarily elevates the priority of the mutex holder to match the blocked high-priority task. Upon releasing the mutex, the holder's original base priority is restored.

flowchart TD
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
    subgraph SchedulerFreeRTOSScheduler ["FreeRTOS Scheduler<br><br><br>"]
        Tick[SysTick Interrupt] -->|"xTaskIncrementTick()"| UnblockCheck[Check Delayed Lists]
        UnblockCheck -->|"Yield()"| SwitchContext[Context Switch PendSV]
    end
    subgraph TaskStateTaskStateMachine ["Task State Machine<br><br><br>"]
        Running -->|"vTaskDelay()"| Blocked
        Blocked -->|"xSemaphoreGive()"| Ready
        Ready -->|"Schedule()"| Running
    end
保存したスキル