Impressive! Very complete on first glance. You might want to soften or qualify the RTOS statement so people focus on its compactness and low latency. As you are already seeing in the comments the RTOS aspect has a lot of opinions depending on what one is trying to accomplish.
peteforde
Very cool! Thanks for sharing.
I would appreciate an honest comparison with FreeRTOS. Building something like this is an excellent learning exercise for the coder, but someone who has to balance the risks, learning curve and feature set has to justify the adventure in a different way.
One thing that would be interesting to hear more about would be your own recounting of the places where you made opinionated decisions about how things should work.
maximusdrex
Looks like a fun project, but I’m curious what you actually tested on. There’s real numbers for estimated context switch timing, and you mentioned implementing context switching, but I can’t find any actual implementations of the context switching routine in your code.
You don’t need to do this yourself, but it’s weird to talk about it if you haven’t.
Retr0id
Did you never even try compiling it?
m132
> Runs on (your target hardware or environment)
Nice try, OpenClaw
Yokohiii
I have no practical insight on RTOS in general, if anyone bothers to give me a hint, please.
From all what I've looked into, RTOS does mean to create software systems that are almost perfectly predictable and safe to execute. Predictable latency, runtime and memory usage, plus maybe side channels to do the unpredictable stuff in between. It's actual rocket science, as no systemic mistakes are allowed.
The confusion is that this project doesn't mention any of it. Is it just hijacking of a fancy acronym, are there two worlds side by side or am I completely misled?
avadodin
You're probably thinking of a hard real-time RTOS with time slices and WCET constraints.
For soft real-time, you basically only need low latency.
Threads with priorities, synchronization primitives and some way of handling interrupts is generally considered good enough.
From the description, this sounds like the kind of RTOS that runs most embedded RT applications currently if perhaps a bit heavier in features than the average with filesystem and networking support.
jtrueb
RTOS can be used a lot looser than you describe. Like a build system, scheduling, and interrupt framework that allows you to program an MCU like you describe. Zephyr RTOS and Free RTOS provide easy enough ways to write code that uses blocking APIs but probably runs your code according to the timing constraints if you hold it right. As an alternative, you could write for “bare metal” and handle the control flow, scheduling, interrupting, etc. yourself. If you are writing to “random” addresses according to some datasheet to effect some real world change, you are probably reaching for an RTOS or bare metal unless you are writing OS driversn. If you look at the linux drivers, you will see a lot of similarities to the Zephyr RTOS drivers, but one of them is probably clocking in the MHz while the other in the GHz
sublinear
> It's actual rocket science, as no systemic mistakes are allowed
Lots of everyday stuff is running on bare metal code that exceeds so-called "real time" requirements without an OS at all, and those programmers are definitely not rocket scientists! :)
peteforde
TIL I learned that I am also a rocket scientist!
I would suggest that a slightly more approachable way to view an RTOS for MCUs is a library that sits on your bare metal that takes primary responsibility for efficiently dividing up available resources across multiple task functions.
An RTOS will usually provide a well documented SDK with support for memory safe queues, semaphores and message brokering.
Think of it as a software enforced contract + best practices to ensure that you get stable, predictable timing loops without ugly polling and blocking.
nofunsir
What ever happened to μC/OS?
Seemed both well documented and well suited to have taken over for the current MCU explosion. I almost never see anyone talk about it.
I've learnt something new: RTOS stands for Real-Time Operating System. Thanks for sharing; your README is top-notch!
jockm
Question: Do you mean real time, meaning there is some kind of expectation of task switching time, nothing can stop other threads from executing, etc; or do you really mean embedded?
Retr0id
It doesn't implement task switching at all...
onetimeusename
How much of this was by AI?
Retr0id
It doesn't even compile, the whole thing is evidently built on vibes.
This was a big deal in some academic circles in the early 2000s
m132
The README mentions Armv7-M, RISC-V, and AVR, but no actual implementations of them that it can run on, and the source code contains unconditional inline assembly for Arm. The scheduler is one big stub that doesn't even enter a task, just returns from its entry point using Arm-specific assembly [0], breaking its own semantics; there's no way any of those examples can run [1]. The bootloader is also a stub [2]. Not a single exception vector table, but plenty of LLM-style comments explaining every single line.
Others have also noted that there's no linker script, no start-up code, and that the project doesn't even build.
82 points at the time of writing, which is 4 hours from the post's submission. Already on the main page. Does anybody read past the headline anymore? Had my hopes higher for this site.
Impressive! Very complete on first glance. You might want to soften or qualify the RTOS statement so people focus on its compactness and low latency. As you are already seeing in the comments the RTOS aspect has a lot of opinions depending on what one is trying to accomplish.
peteforde
Very cool! Thanks for sharing.
I would appreciate an honest comparison with FreeRTOS. Building something like this is an excellent learning exercise for the coder, but someone who has to balance the risks, learning curve and feature set has to justify the adventure in a different way.
One thing that would be interesting to hear more about would be your own recounting of the places where you made opinionated decisions about how things should work.
maximusdrex
Looks like a fun project, but I’m curious what you actually tested on. There’s real numbers for estimated context switch timing, and you mentioned implementing context switching, but I can’t find any actual implementations of the context switching routine in your code.
You don’t need to do this yourself, but it’s weird to talk about it if you haven’t.
Retr0id
Did you never even try compiling it?
m132
> Runs on (your target hardware or environment)
Nice try, OpenClaw
Yokohiii
I have no practical insight on RTOS in general, if anyone bothers to give me a hint, please.
From all what I've looked into, RTOS does mean to create software systems that are almost perfectly predictable and safe to execute. Predictable latency, runtime and memory usage, plus maybe side channels to do the unpredictable stuff in between. It's actual rocket science, as no systemic mistakes are allowed.
The confusion is that this project doesn't mention any of it. Is it just hijacking of a fancy acronym, are there two worlds side by side or am I completely misled?
avadodin
You're probably thinking of a hard real-time RTOS with time slices and WCET constraints.
For soft real-time, you basically only need low latency.
Threads with priorities, synchronization primitives and some way of handling interrupts is generally considered good enough.
From the description, this sounds like the kind of RTOS that runs most embedded RT applications currently if perhaps a bit heavier in features than the average with filesystem and networking support.
jtrueb
RTOS can be used a lot looser than you describe. Like a build system, scheduling, and interrupt framework that allows you to program an MCU like you describe. Zephyr RTOS and Free RTOS provide easy enough ways to write code that uses blocking APIs but probably runs your code according to the timing constraints if you hold it right. As an alternative, you could write for “bare metal” and handle the control flow, scheduling, interrupting, etc. yourself. If you are writing to “random” addresses according to some datasheet to effect some real world change, you are probably reaching for an RTOS or bare metal unless you are writing OS driversn. If you look at the linux drivers, you will see a lot of similarities to the Zephyr RTOS drivers, but one of them is probably clocking in the MHz while the other in the GHz
sublinear
> It's actual rocket science, as no systemic mistakes are allowed
Lots of everyday stuff is running on bare metal code that exceeds so-called "real time" requirements without an OS at all, and those programmers are definitely not rocket scientists! :)
peteforde
TIL I learned that I am also a rocket scientist!
I would suggest that a slightly more approachable way to view an RTOS for MCUs is a library that sits on your bare metal that takes primary responsibility for efficiently dividing up available resources across multiple task functions.
An RTOS will usually provide a well documented SDK with support for memory safe queues, semaphores and message brokering.
Think of it as a software enforced contract + best practices to ensure that you get stable, predictable timing loops without ugly polling and blocking.
nofunsir
What ever happened to μC/OS?
Seemed both well documented and well suited to have taken over for the current MCU explosion. I almost never see anyone talk about it.
I've learnt something new: RTOS stands for Real-Time Operating System. Thanks for sharing; your README is top-notch!
jockm
Question: Do you mean real time, meaning there is some kind of expectation of task switching time, nothing can stop other threads from executing, etc; or do you really mean embedded?
Retr0id
It doesn't implement task switching at all...
onetimeusename
How much of this was by AI?
Retr0id
It doesn't even compile, the whole thing is evidently built on vibes.
This was a big deal in some academic circles in the early 2000s
m132
The README mentions Armv7-M, RISC-V, and AVR, but no actual implementations of them that it can run on, and the source code contains unconditional inline assembly for Arm. The scheduler is one big stub that doesn't even enter a task, just returns from its entry point using Arm-specific assembly [0], breaking its own semantics; there's no way any of those examples can run [1]. The bootloader is also a stub [2]. Not a single exception vector table, but plenty of LLM-style comments explaining every single line.
Others have also noted that there's no linker script, no start-up code, and that the project doesn't even build.
82 points at the time of writing, which is 4 hours from the post's submission. Already on the main page. Does anybody read past the headline anymore? Had my hopes higher for this site.
Hi HN,
I’ve been working on a tiny RTOS as a personal project to better understand how operating systems and schedulers work internally.
This project includes: - Basic task scheduler - Context switching - Simple memory management - Runs on (your target hardware or environment)
Motivation: I wanted to learn OS internals by building everything from scratch rather than relying on existing frameworks.
Challenges: - Implementing context switching correctly - Designing a minimal but usable scheduler - Keeping the codebase simple and readable
I’d really appreciate feedback, especially on: - Architecture design - Scheduler implementation - Code structure
GitHub: https://github.com/cmc-labo/tinyos-rtos
Impressive! Very complete on first glance. You might want to soften or qualify the RTOS statement so people focus on its compactness and low latency. As you are already seeing in the comments the RTOS aspect has a lot of opinions depending on what one is trying to accomplish.
Very cool! Thanks for sharing.
I would appreciate an honest comparison with FreeRTOS. Building something like this is an excellent learning exercise for the coder, but someone who has to balance the risks, learning curve and feature set has to justify the adventure in a different way.
One thing that would be interesting to hear more about would be your own recounting of the places where you made opinionated decisions about how things should work.
Looks like a fun project, but I’m curious what you actually tested on. There’s real numbers for estimated context switch timing, and you mentioned implementing context switching, but I can’t find any actual implementations of the context switching routine in your code. You don’t need to do this yourself, but it’s weird to talk about it if you haven’t.
Did you never even try compiling it?
> Runs on (your target hardware or environment)
Nice try, OpenClaw
I have no practical insight on RTOS in general, if anyone bothers to give me a hint, please. From all what I've looked into, RTOS does mean to create software systems that are almost perfectly predictable and safe to execute. Predictable latency, runtime and memory usage, plus maybe side channels to do the unpredictable stuff in between. It's actual rocket science, as no systemic mistakes are allowed. The confusion is that this project doesn't mention any of it. Is it just hijacking of a fancy acronym, are there two worlds side by side or am I completely misled?
You're probably thinking of a hard real-time RTOS with time slices and WCET constraints.
For soft real-time, you basically only need low latency.
Threads with priorities, synchronization primitives and some way of handling interrupts is generally considered good enough.
From the description, this sounds like the kind of RTOS that runs most embedded RT applications currently if perhaps a bit heavier in features than the average with filesystem and networking support.
RTOS can be used a lot looser than you describe. Like a build system, scheduling, and interrupt framework that allows you to program an MCU like you describe. Zephyr RTOS and Free RTOS provide easy enough ways to write code that uses blocking APIs but probably runs your code according to the timing constraints if you hold it right. As an alternative, you could write for “bare metal” and handle the control flow, scheduling, interrupting, etc. yourself. If you are writing to “random” addresses according to some datasheet to effect some real world change, you are probably reaching for an RTOS or bare metal unless you are writing OS driversn. If you look at the linux drivers, you will see a lot of similarities to the Zephyr RTOS drivers, but one of them is probably clocking in the MHz while the other in the GHz
> It's actual rocket science, as no systemic mistakes are allowed
Lots of everyday stuff is running on bare metal code that exceeds so-called "real time" requirements without an OS at all, and those programmers are definitely not rocket scientists! :)
TIL I learned that I am also a rocket scientist!
I would suggest that a slightly more approachable way to view an RTOS for MCUs is a library that sits on your bare metal that takes primary responsibility for efficiently dividing up available resources across multiple task functions.
An RTOS will usually provide a well documented SDK with support for memory safe queues, semaphores and message brokering.
Think of it as a software enforced contract + best practices to ensure that you get stable, predictable timing loops without ugly polling and blocking.
What ever happened to μC/OS?
Seemed both well documented and well suited to have taken over for the current MCU explosion. I almost never see anyone talk about it.
Looks like it open-sourced in 2020.
https://github.com/weston-embedded
I've learnt something new: RTOS stands for Real-Time Operating System. Thanks for sharing; your README is top-notch!
Question: Do you mean real time, meaning there is some kind of expectation of task switching time, nothing can stop other threads from executing, etc; or do you really mean embedded?
It doesn't implement task switching at all...
How much of this was by AI?
It doesn't even compile, the whole thing is evidently built on vibes.
this reminds me of: https://github.com/tinyos/tinyos-main more than one decade ago
I thought this was about UC Berkeley's TinyOS: https://github.com/tinyos/tinyos-main
This was a big deal in some academic circles in the early 2000s
The README mentions Armv7-M, RISC-V, and AVR, but no actual implementations of them that it can run on, and the source code contains unconditional inline assembly for Arm. The scheduler is one big stub that doesn't even enter a task, just returns from its entry point using Arm-specific assembly [0], breaking its own semantics; there's no way any of those examples can run [1]. The bootloader is also a stub [2]. Not a single exception vector table, but plenty of LLM-style comments explaining every single line.
Others have also noted that there's no linker script, no start-up code, and that the project doesn't even build.
82 points at the time of writing, which is 4 hours from the post's submission. Already on the main page. Does anybody read past the headline anymore? Had my hopes higher for this site.
[0] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...
[1] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...
[2] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...
Hi HN,
I’ve been working on a tiny RTOS as a personal project to better understand how operating systems and schedulers work internally.
This project includes: - Basic task scheduler - Context switching - Simple memory management - Runs on (your target hardware or environment)
Motivation: I wanted to learn OS internals by building everything from scratch rather than relying on existing frameworks.
Challenges: - Implementing context switching correctly - Designing a minimal but usable scheduler - Keeping the codebase simple and readable
I’d really appreciate feedback, especially on: - Architecture design - Scheduler implementation - Code structure
GitHub: https://github.com/cmc-labo/tinyos-rtos
Impressive! Very complete on first glance. You might want to soften or qualify the RTOS statement so people focus on its compactness and low latency. As you are already seeing in the comments the RTOS aspect has a lot of opinions depending on what one is trying to accomplish.
Very cool! Thanks for sharing.
I would appreciate an honest comparison with FreeRTOS. Building something like this is an excellent learning exercise for the coder, but someone who has to balance the risks, learning curve and feature set has to justify the adventure in a different way.
One thing that would be interesting to hear more about would be your own recounting of the places where you made opinionated decisions about how things should work.
Looks like a fun project, but I’m curious what you actually tested on. There’s real numbers for estimated context switch timing, and you mentioned implementing context switching, but I can’t find any actual implementations of the context switching routine in your code. You don’t need to do this yourself, but it’s weird to talk about it if you haven’t.
Did you never even try compiling it?
> Runs on (your target hardware or environment)
Nice try, OpenClaw
I have no practical insight on RTOS in general, if anyone bothers to give me a hint, please. From all what I've looked into, RTOS does mean to create software systems that are almost perfectly predictable and safe to execute. Predictable latency, runtime and memory usage, plus maybe side channels to do the unpredictable stuff in between. It's actual rocket science, as no systemic mistakes are allowed. The confusion is that this project doesn't mention any of it. Is it just hijacking of a fancy acronym, are there two worlds side by side or am I completely misled?
You're probably thinking of a hard real-time RTOS with time slices and WCET constraints.
For soft real-time, you basically only need low latency.
Threads with priorities, synchronization primitives and some way of handling interrupts is generally considered good enough.
From the description, this sounds like the kind of RTOS that runs most embedded RT applications currently if perhaps a bit heavier in features than the average with filesystem and networking support.
RTOS can be used a lot looser than you describe. Like a build system, scheduling, and interrupt framework that allows you to program an MCU like you describe. Zephyr RTOS and Free RTOS provide easy enough ways to write code that uses blocking APIs but probably runs your code according to the timing constraints if you hold it right. As an alternative, you could write for “bare metal” and handle the control flow, scheduling, interrupting, etc. yourself. If you are writing to “random” addresses according to some datasheet to effect some real world change, you are probably reaching for an RTOS or bare metal unless you are writing OS driversn. If you look at the linux drivers, you will see a lot of similarities to the Zephyr RTOS drivers, but one of them is probably clocking in the MHz while the other in the GHz
> It's actual rocket science, as no systemic mistakes are allowed
Lots of everyday stuff is running on bare metal code that exceeds so-called "real time" requirements without an OS at all, and those programmers are definitely not rocket scientists! :)
TIL I learned that I am also a rocket scientist!
I would suggest that a slightly more approachable way to view an RTOS for MCUs is a library that sits on your bare metal that takes primary responsibility for efficiently dividing up available resources across multiple task functions.
An RTOS will usually provide a well documented SDK with support for memory safe queues, semaphores and message brokering.
Think of it as a software enforced contract + best practices to ensure that you get stable, predictable timing loops without ugly polling and blocking.
What ever happened to μC/OS?
Seemed both well documented and well suited to have taken over for the current MCU explosion. I almost never see anyone talk about it.
Looks like it open-sourced in 2020.
https://github.com/weston-embedded
I've learnt something new: RTOS stands for Real-Time Operating System. Thanks for sharing; your README is top-notch!
Question: Do you mean real time, meaning there is some kind of expectation of task switching time, nothing can stop other threads from executing, etc; or do you really mean embedded?
It doesn't implement task switching at all...
How much of this was by AI?
It doesn't even compile, the whole thing is evidently built on vibes.
this reminds me of: https://github.com/tinyos/tinyos-main more than one decade ago
I thought this was about UC Berkeley's TinyOS: https://github.com/tinyos/tinyos-main
This was a big deal in some academic circles in the early 2000s
The README mentions Armv7-M, RISC-V, and AVR, but no actual implementations of them that it can run on, and the source code contains unconditional inline assembly for Arm. The scheduler is one big stub that doesn't even enter a task, just returns from its entry point using Arm-specific assembly [0], breaking its own semantics; there's no way any of those examples can run [1]. The bootloader is also a stub [2]. Not a single exception vector table, but plenty of LLM-style comments explaining every single line.
Others have also noted that there's no linker script, no start-up code, and that the project doesn't even build.
82 points at the time of writing, which is 4 hours from the post's submission. Already on the main page. Does anybody read past the headline anymore? Had my hopes higher for this site.
[0] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...
[1] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...
[2] https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45...