3 ms·
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
by hpscript 7mo ago
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 https://github.com/cmc-labo/tinyos-rtos
- Retr0id 7mo agoDid you never even try compiling it?
- bahmboo 7mo agoImpressive! 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 7mo agoVery 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 7mo agoLooks 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 7mo agohttps://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45f6f33246a33ef4fc9a5d7e4de/src/kernel.c#L106 https://github.com/cmc-labo/tinyos-rtos/blob/2a47496047fdb45... "Context switch (to be implemented in assembly for target architecture)" There's no asm in the repo so I can only assume this is not something that actually compiles and runs. Other things that are missing: - No startup code (stack setup etc.) - No linker script ("to be created", per makefile comment)
- maximusdrex 7mo agoYeah, I read that note and stopped looking further. I was hoping that maybe the hardware-specific code was in a different project and just wanted to be nice in case. I just don’t get the point of making AI slop out of something like a toy RTOS, which is inherently a learning project more than anything else. There’s nothing even fun about doing it if you won’t even try to get it to run on an STM32 or something.
- m132 7mo ago> Runs on (your target hardware or environment) Nice try, OpenClaw