# 1919884213/tinyrtos architecture

> Architecture diagram of the GitHub repository 1919884213/tinyrtos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/1919884213/tinyrtos
- Repository: https://github.com/1919884213/tinyrtos

## Overview

TinyRTOS is a small, statically allocated preemptive RTOS kernel for STM32F407. Firmware startup initializes the board, registers an idle task and a selected demo’s tasks, then starts scheduling; tasks exercise delays and synchronization, while the tick drives wakeups and time slicing. The README documents PendSV context switching and kernel behavior, but the tree lists no switch.s file and excerpts do not expose all interrupt or primitive internals, so uncertain implementation links are omitted.

Main entry points: [`Core/User/rtos/kernel.c`](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/kernel.c) (Scheduler and tasks), [`Core/User/app/os_examples.c`](https://github.com/1919884213/tinyrtos/blob/master/Core/User/app/os_examples.c) (Demo and idle tasks), [`Core/Src/main.c`](https://github.com/1919884213/tinyrtos/blob/master/Core/Src/main.c) (Boot and main), [`Core/Src/usart.c`](https://github.com/1919884213/tinyrtos/blob/master/Core/Src/usart.c) (USART1 driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware startup"]
  node_main["Boot and main<br/>[main.c]"]
  node_usart["USART1 driver<br/>[usart.c]"]
  node_interrupts["Interrupt handlers<br/>[stm32f4xx_it.c]"]
end

subgraph group_kernel["RTOS kernel"]
  node_kernel["Scheduler and tasks<br/>[kernel.c]"]
  node_tcb["Task state<br/>[tcb.h]"]
  node_port["Critical sections<br/>[port.h]"]
end

subgraph group_sync["Synchronization"]
  node_semaphore["Semaphore<br/>[sem.c]"]
  node_queue["Message queue<br/>[queue.c]"]
  node_mutex["Mutex and inheritance<br/>[mutex.c]"]
end

subgraph group_demo["Demo tasks"]
  node_examples_init["Demo setup<br/>[os_examples.c]"]
  node_tasks["Demo and idle tasks<br/>[os_examples.c]"]
end

node_board(("STM32F407"))

node_board -->|"boots"| node_main
node_main -->|"initializes demos"| node_examples_init
node_main -->|"starts OS"| node_kernel
node_main -->|"initializes UART"| node_usart
node_examples_init -->|"creates tasks"| node_kernel
node_examples_init -->|"initializes"| node_semaphore
node_examples_init -->|"initializes"| node_queue
node_examples_init -->|"initializes"| node_mutex
node_tasks -->|"delays, yields, deletes"| node_kernel
node_tasks -->|"signals and waits"| node_semaphore
node_tasks -->|"sends and receives"| node_queue
node_tasks -->|"locks and unlocks"| node_mutex
node_tasks -->|"prints via UART"| node_usart
node_interrupts -->|"ticks scheduler"| node_kernel
node_kernel -->|"updates task state"| node_tcb
node_kernel -->|"protects kernel"| node_port

click node_main "https://github.com/1919884213/tinyrtos/blob/master/Core/Src/main.c"
click node_usart "https://github.com/1919884213/tinyrtos/blob/master/Core/Src/usart.c"
click node_interrupts "https://github.com/1919884213/tinyrtos/blob/master/Core/Src/stm32f4xx_it.c"
click node_examples_init "https://github.com/1919884213/tinyrtos/blob/master/Core/User/app/os_examples.c"
click node_tasks "https://github.com/1919884213/tinyrtos/blob/master/Core/User/app/os_examples.c"
click node_kernel "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/kernel.c"
click node_tcb "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/tcb.h"
click node_port "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/port.h"
click node_semaphore "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/sem.c"
click node_queue "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/queue.c"
click node_mutex "https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/mutex.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_usart,node_interrupts toneBlue
class node_kernel,node_tcb,node_port toneAmber
class node_semaphore,node_queue,node_mutex toneMint
class node_examples_init,node_tasks toneRose
class node_board toneIndigo
```

## Components

### Firmware startup

- [Boot and main](https://github.com/1919884213/tinyrtos/blob/master/Core/Src/main.c): `Core/Src/main.c`
- [USART1 driver](https://github.com/1919884213/tinyrtos/blob/master/Core/Src/usart.c): `Core/Src/usart.c`
- [Interrupt handlers](https://github.com/1919884213/tinyrtos/blob/master/Core/Src/stm32f4xx_it.c): `Core/Src/stm32f4xx_it.c`

### RTOS kernel

- [Scheduler and tasks](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/kernel.c): `Core/User/rtos/kernel.c`
- [Task state](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/tcb.h): `Core/User/rtos/tcb.h`
- [Critical sections](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/port.h): `Core/User/rtos/port.h`

### Synchronization

- [Semaphore](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/sem.c): `Core/User/rtos/sem.c`
- [Message queue](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/queue.c): `Core/User/rtos/queue.c`
- [Mutex and inheritance](https://github.com/1919884213/tinyrtos/blob/master/Core/User/rtos/mutex.c): `Core/User/rtos/mutex.c`

### Demo tasks

- [Demo setup](https://github.com/1919884213/tinyrtos/blob/master/Core/User/app/os_examples.c): `Core/User/app/os_examples.c`
- [Demo and idle tasks](https://github.com/1919884213/tinyrtos/blob/master/Core/User/app/os_examples.c): `Core/User/app/os_examples.c`

### Other components

- **STM32F407**

## Connections

- STM32F407 → Boot and main: boots
- Boot and main → Demo setup: initializes demos
- Boot and main → Scheduler and tasks: starts OS
- Boot and main → USART1 driver: initializes UART
- Demo setup → Scheduler and tasks: creates tasks
- Demo setup → Semaphore: initializes
- Demo setup → Message queue: initializes
- Demo setup → Mutex and inheritance: initializes
- Demo and idle tasks → Scheduler and tasks: delays, yields, deletes
- Demo and idle tasks → Semaphore: signals and waits
- Demo and idle tasks → Message queue: sends and receives
- Demo and idle tasks → Mutex and inheritance: locks and unlocks
- Demo and idle tasks → USART1 driver: prints via UART
- Interrupt handlers → Scheduler and tasks: ticks scheduler
- Scheduler and tasks → Task state: updates task state
- Scheduler and tasks → Critical sections: protects kernel
