I wrote one for an 8080 in 1981 for a custom industrial SBC. It is still in use in a few places in the world today.
@MrJegerjeg5 ай бұрын
Well, now I am impressed!
@blackcathardware62385 ай бұрын
Impressed,too. Especially as the first Computer I ever saw was a CBM 3032 in 1984/85.
@1jnk6 ай бұрын
We got Suckless OS before GTA6
@ZE_TRVTH_NVKE6 ай бұрын
Saving this OS to a disquette with a note "Linux is depricated." and mailing it to Linus.
@Tenraiden6 ай бұрын
GTA sucks
@blackice34035 ай бұрын
@@Tenraidentrue
@alexsteve6475 ай бұрын
@@blackice3403false
@st203325 ай бұрын
online does, story doesn't @@Tenraiden
@優さん-n7m6 ай бұрын
I waited for something like this since 2006
@Jupiter__001_6 ай бұрын
You could install an RTOS from a USB stick if you wanted. Interestingly BlackBerryOS was real-time despite being a user-facing OS.
@eekee60346 ай бұрын
Linux developed real-time features in the early 00s. Windows may have had some degree of real-time support earlier as it's desirable for games and media. Both OSs certainly have real-time support now. Only critical applications really need stripped down OSs.
@trejohnson76776 ай бұрын
i find it hilarious we call them real time operating systems, when they should be called defined time.
@marcombo016 ай бұрын
I think most cars infotainment systems run on a RTOS. And maybe that's reason why most car infotainment are still really bad even today
@adversemiller6 ай бұрын
@@marcombo01 most cars run android (linux), so you would be right about that
@anonymousarmadillo65896 ай бұрын
Android OS isn't real time by any stretch of the imagination @@adversemiller
@Gersberms6 ай бұрын
Very impressive! I've wondered for like 20 years how a multi tasking operating system would switch mid-task to the next process. Now I know a lot more about this process.
@maksymiliank51356 ай бұрын
This process on a OS like linux, windows, macos is a lot more complicated but the same ideas apply. There is a process called scheduler which schedules when each task should be executed. There are some mechanism to adjust priority so that some tasks won't "starve" (they will be executed at some point even if their priority is very low)
@zach4306 ай бұрын
Yes nowadays they mash all the basic scheduling principles into one scheduler
@Gersberms6 ай бұрын
@@maksymiliank5135 I understand. Memory management and all that, process isolation. With this scheduler here any function can access whatever it wants.
@JacobsKrąnųg5 ай бұрын
if you were really curious, you would know it by now. its not that hard to google it
@RegisMichelLeclerc6 ай бұрын
The microcontroller in Arduino was originally an atMega8 at 16MHz, replaced by an atMega328P (at 16MHz too, but upgradable to 20MHz), which is the argument you passed to AVRDude. Now, to be fair, using interrupts (especially the CLK one) is catastrophic in terms of timewaste and stack management. You're better putting counters and have a switch/case in your "main" loop that calls functions by pointer. From there, you can craft your functions so they perform an atomic part of the entire task every time they're called (such as updating the screen, turning one LED on or off in a field of LEDs, etc.). Interrupts are cool, but that's admitting the defeat of intelligence by paying incompetece with clock cycles.
@Freshbott26 ай бұрын
Thanks for sharing this, I’d never even considered that it could even be any different to any normal operating system.
@eekee60346 ай бұрын
If you don't use interrupts, your user code had better not go into a long loop without calling the OS. It can be done, but you have to carefully craft everything in little chunks as you implied, with, for safety, no longer-running background processes. If you have background processes, they themselves will have to waste time and stack space yielding to the kernel just in case, and woe betide you if a bug causes such yielding to be skipped.
@simontillson4826 ай бұрын
Not every task can be done in small steps. Also, crafting functions to operate in this way is often very inefficient in practise. There are many, many use cases where preemptive multitasking is not just preferable but an absolute requirement.
@superxpro126 ай бұрын
Using an isr allows for preemptive task interruption, not cooperative. On ultra low power micros you don't get a dedicated CPU isr operation like pendsv for this purpose, so you have to use a timer.
@RegisMichelLeclerc6 ай бұрын
@@simontillson482 That's why I'm mentioning the stack: you better be very reentrant if you use preemptive multitasking, and ve even more cautious about the timings of what interrupts what. I prefer keeping my interrupts for low-level signals and use a "token-loop" (by analogy to "token-ring") for time-based stuff. In that way, yes, everything can be decomposed in micro-tasks, it just takes a different way of thinking them with a lot of pointers and global variables.
@mecitpamuk56235 ай бұрын
Thats good for only periodic tasks. We also have inter task communucation. Meaning that task b can send an event to task a in that case an asyncronous preemption can be needed!
@jwd.t6 ай бұрын
Man, where have you been all these days?
@dzm_mlc6 ай бұрын
I just cant describe amount of problems you'll get when using such approach, it's completely wrong. Just never use interrupts like this, that's not what they meant for. Never call user code bigger that assigning value to a register/shared memory from ISR. Never enable interrupts from ISR unless you want another high-priority interrupt to be called. And never use nested interrupts like this - its a way to stack overflow, only use it when it's necessary to handle event in time. If you want just run some code "simultaniousely" just add all your "tasks" into for() loop and in every task add check for timeout and do something only when timeouted (see how Runnables in AUTOSAR works)
@un2mensch5 ай бұрын
Every single thing you've listed as problematic is, in reality, a perfectly relevant and solid way to implement things if they result in the desired behavior / functionality. Just because you have in mind an extremely specific and limited design does not make other approaches wrong.
@whiteingale5 ай бұрын
OKAY, "magic man" but I didn't hear you say "Big McThankie from McSpankie" to the customers.
@dzm_mlc4 ай бұрын
@@un2mensch There is many ways and shortcuts to satisfy customers requirements, however, smart engineers tried them all for us and concidered some of them as problematic and hard to maintain, unreliable and unsafe. You can always go your own way in development, however one day when reached enough expertise you'll find that these smart engineers was right. This is what engineereng education for - to not waste your time for dead-end approaches
@ivanmaglica2645 ай бұрын
I don't think I would consider this as an OS, it still fits more into runtime category. Having a loader for external binary executables is I think an essential part to qualify as OS, otherwise it's just statically compiled task scheduler. Good stuff thou, especially for learning, and still very useful. Registers not being pushed to and popped from stack between task switching is a bit concerning. Guess this has to be done by task itself.
@donaldwright242620 күн бұрын
Thanks for the explanations. I'm writing a tiny RTOS for the MEGA 2560 (that's because it's what I have) and what is propose by RIOS is close to what I'm looking but lack of small features. PORTB = 0xff is to enable all 8 ports of port B as outputs. 🙂
@josealejandrovaroncarreno16926 ай бұрын
excelent video, please continue
@lets_lvl_up5 ай бұрын
avrdude..... gr8 naming right there
@trejohnson76776 ай бұрын
*laughs in solar flare on unhardened chip*. really though, this a nice exposition, its got the bones.
@eekee60346 ай бұрын
A char in a struct full of ints won't save any memory unless your compiler packs structs. Packed structs mean unaligned access which is slow on most architectures. Even some models of x86 (which has unaligned opcodes) have slow unaligned access to data. I don't know the native word size of the CPU you're using. Any larger than a byte and you don't want to pack.
@jojoposter6 ай бұрын
The avr is an 8bit cpu. So aligned means 8bit or byte-aligned on this architecture.
@eekee60346 ай бұрын
@@jojoposter Ah, thanks! I should have looked it up before writing all that. :)
@anon_y_mousse5 ай бұрын
@@eekee6034 While it is technically true that misaligned memory accesses will be slower, unless you're living in the early aughts or earlier you might as well just do it anyway. Back a couple of decades ago when I was on Win98 using a 533mhz Celery, I ran all kinds of tests and found that if you can align before a bunch of looped reads/writes, then do so, but if you couldn't it was only a 15% hit on performance, and that was back then. Now the performance hit is negligible and only long-running server applications ever really have to pay that cost.
@eekee60345 ай бұрын
@@anon_y_mousse I'm sorry, but progress isn't always linear like that. Listening to my OS-developing friends in the 2010s, I learned some Intel and other CPUs were not good with unaligned access. I don't know how bad they were, but these weren't performance nuts. (They were simplicity nuts.) Anyway, 10% is my upper limit for thinking of something as minor.
@anon_y_mousse5 ай бұрын
@@eekee6034 Negligible for most applications is less than 5%, but unless you're doing tons of copying all over the place, you're never going to hit that high. What's more is that you literally can't always align every pointer when dealing with large buffers. This is part of the reason why most allocators waste a little extra space when allocating to ensure that pointers are aligned on specific boundaries, but then it's up to you to align the data when dealing with structs. All of this is of course a moot point when it comes to 8-bit processors, but it's essentially irrelevant for most people anyway on modern 64-bit processors.
@jon91035 ай бұрын
RTOS doesn't mean a basic OS, though they typically are. It means that they are designed to handle real-time constraints which is difficult to do on bloated OSes, hence why they tend to be stripped down, bare bones implementations.
@cheesed_up5 ай бұрын
If I could pin a comment, this would probably be it :D
@cryptic_daemon_6 ай бұрын
"...it gonna run minecraft..." me: and I took that personally
@esra_erimez5 ай бұрын
This was so informative and interesting
@GroovThe6 ай бұрын
Right, that makes a lot of sense. RTOSs allow this structure of overlapping periodic tasks. This seems like a very basic and common requirement. The existence of RIOS bags the question then, why use something bigger like freeRTOS, or even pay for one? What's the thing that makes RIOS non-viable for "real" projects?
@kriszSTNX06 ай бұрын
How complex, time consuming can the tick function be? If none of the tasks finishes before the next interrupt, is the avr gonna crash bc of stack overflow?
@Thecommet6 ай бұрын
Yep, from the looks of it. He also starts the timer and enables global interrupts before initializing the task structures
@caspianmaclean81223 ай бұрын
It looks like once the highest priority task is running, the next interrupt should quickly see there's no higher priority tasks left to start, and exit. So possibly it won't overflow, at least I think this approach could be made to avoid overflowing if all the tasks can fit on the stack at once.
@arduous2225 ай бұрын
0:18 Bold of you to assume that my OS can run Minecraft.
@johnschmidt8746 ай бұрын
Nice video! I've just subscribed to your channel.
@blackmagicprod70396 ай бұрын
Any chance you’d be willing to give high-precision, high-accuracy timing tasks a try with a tiny RTOS like this? I’m VERY interested in various applications of high-precision timing in small consumer devices. I’m trying to figure out how accurate AND precise you could get, for example: with an Arduino, a GPS module, and an oven-controlled oscillator (and ideally without breaking the bank). Imagine a system such as that with an antenna connected (even just a long wire on a GPIO pin) that’s listening for the low frequency bangs of lightning flashes. Like, with 3 of them, what would be the minimum separation necessary between the units to localize a lightning strike to within 10m? The timing requirements for an application like lightning localization become very extreme very quickly, and I am a complete novice. Uncertainty about precisely how the processor will schedule execution is fatal to an application like that where microseconds means literal miles of difference. Anyway, just an idea to consider. Lots of very interesting applications for RTOS… Liked the video and subbed
@cheesed_up6 ай бұрын
Hey, very interesting ideas you have there! I'm gonna be frank - I don't have the expertise to dive this deep into this topic. That said, I would be very interested to see if you ever come up with something like this! I'm glad you liked the video! Good luck on your journey!
@blackmagicprod70396 ай бұрын
@@cheesed_up Thanks for your consideration and for your honest reply! I’ve been kicking around several ideas along these lines for many months, and seriously investigating this specific application for a few weeks. I don’t think I’ll stop until it’s done, but I also probably won’t document it on KZbin. Do you have a discord or something? Otherwise I guess I’ll just come back to this comment and update you 😅
@mindasb6 ай бұрын
@@blackmagicprod7039very interesting idea. I would be interested in hearing more ideas and also the updates if you decide to implemwnt them
@elias-ou2sp6 ай бұрын
okay, now create a lisp machine.
@ItsCOMMANDer_5 ай бұрын
Looks cool, maybe i'll make my own using a round robin sheduler, i'll see
@rescyy22356 ай бұрын
8:14 "we need to enable our GPIO pins", sure buddy, pins
@pecfexfextus6 ай бұрын
wondering the same thing
@cheesed_up4 ай бұрын
I thought I enabled interrupts and initialized GPIO pins. Must have heard it wrong :D
@rescyy22354 ай бұрын
@@cheesed_up ah no, that's not what I meant, I have nothing against what you did in the video. I was referring to the way you said PINS.
@viewerguy103 ай бұрын
Lol the auto-generated subtitles was way off.
@gerooq5 ай бұрын
Very cool but how is this actually different from just regular old embedded programming?
@cheesed_up5 ай бұрын
I don't think it's different. This is just an example of how a basic preemptive scheduler might look like.
@Prescott2400-my6di6 ай бұрын
I want a queue! Where are my queue! I want a queue on my desk until the end of the world! 😡
@thegermantomoeser5 ай бұрын
Ahh, that was great.
@RasitEvduzen5 ай бұрын
Actually this is very similar to time driven non-cooperative multitasking system.
@ferroalloys5945 ай бұрын
Why is the ancient "pseudo-metric" of 'lines of code' used? Indeed, why use the misread term "code" at all, what conventional use of the term conventionally associated with ways of encryption/decryption was involved, none? How many actual TERMINAL SYMBOLS in the SOURCE DESCRIPTION (that are often mistakenly termed "code") were involved? Now, maybe there's an actual textual metric with some meaning? Simples ):-)
@cheesed_up4 ай бұрын
clickbait!! In all seriousness - I just didn't have a better idea how to name the series of videos. I'm sorry if it's a bit annoying!
@ferroalloys5944 ай бұрын
No problem! Thanks indeed for your reply, much appreciated... ):-)
@DwAboutItManFr6 ай бұрын
No assembly?
@anon_y_mousse5 ай бұрын
I suspect the goal was portability. Different microcontrollers will require different instruction mnemonics. It seems stupid when you think about it, but it's generally the processor manufacturer that supplies the assembler and thus requires whatever mnemonics they want even if they mean basically the same thing between 100 different chips. Granted, it doesn't make it any easier when different chips will require a different amount of operands to an `add` instruction, think ARM versus x86, but that's easily solved by requiring two operand chips to have the mnemonic of repeating the destination or three operand chips of allowing for a mnemonic of not repeating the destination when it's the same as the next operand.
@hugopontes49895 ай бұрын
How come you are running the task functions from inside the timer ISR? For this the timer interrupt must be set to the lowest priority (so that other interrupts still seem like interrupts)? And the timer interrupt can interrupt itself recursively? Is that a good idea?
@cheesed_up4 ай бұрын
Not sure if it's a good idea if you are the one maintaining the code. But if I remember correctly, freeRTOS does something like this as well.
@fishsayhelo98725 ай бұрын
very gud 👍
@swgman6 ай бұрын
How did you know I was playing minecraft when I was watching 0:23
@Kalumbatsch5 ай бұрын
Not sure if a minimalist scheduler running on a microcontroller qualifies as an operating system, but hey. It's kind of cute.
@cheesed_up5 ай бұрын
To add to this: I'm not sure if an RTOS qualifies as an operating system :D
@poparab5 ай бұрын
real time means you have a time on a computer, and only this time is valid for all on the system. that has nothing to do with it was 7.00 in the morning. Robotic time is with special time cards.
@cheesed_up4 ай бұрын
Not sure if that's 100% correct - real time in this context means that ceratain operations need to execute WITHIN a certain timeline or EXACTLY at a certain times (hard real time). Thanks for the comment!
@hatsuneadc6 ай бұрын
Very nice
@cvabds6 ай бұрын
Now do templeOS
@maiconloure6 ай бұрын
Don't depend on one resource
@thomasluk43196 ай бұрын
what theme are you using
@cheesed_up6 ай бұрын
I think it's something like "gleam theme" - found it randomly in vscode extension store.
@tugaric6 ай бұрын
*hears russian accent* ohh boy I nees to see this one
@friedrichmyers6 ай бұрын
Fr. Tsoding also has an accent and that's how I knew the mf was real
@cheesed_up6 ай бұрын
Not Russian, but yeah it's slavic :D
@youtube-is-cringe6 ай бұрын
nice
@platin21486 ай бұрын
Well its bigger than that as it requires interrupt library.
@emilien.breton6 ай бұрын
Pushing aside my opinion that library line counts should be excluded anyway, `io.h` and `interrupt.h` are basically a bunch of one-liner `#define`s and so hard-coding everything wouldn't even increase client line count.
@Tenraiden6 ай бұрын
Could've made that in fewer lines if you knew about for loops lol
@earth2k666 ай бұрын
This model is used in RP2040 c-sdk's async_context module too. Very useful for doing pseudo async stuff without wasting cpu cycles. The only thing lacking in the model is the same pseudo sleep() that would save the state of a task and jump to next tusks then resumes the sleeping task when timeout is over. Back in the day I first read about this concept of pseudo sleep in python with generators (yield), then they actually came up with the same concept in python asyncio. However there is probably no way to do this in pure C without getting into assembly like RTOS.
@user-sq1oi9qp8w6 ай бұрын
what font in thumbnail?
@cheesed_up6 ай бұрын
Comic Code - I recommend you search youtube if you wanna find out more.
@RichardLofty6 ай бұрын
MsDOS works in real mode.
@typedef_5 ай бұрын
I only understood line 26
@imakhlaqXD6 ай бұрын
You dont care about hardware writing "javascript". Lool good one
@alaricgorb6 ай бұрын
free retos
@Kyoz5 ай бұрын
🤍
@mad_t5 ай бұрын
96 lines my ass. Try to count lines including headers ;)
@cheesed_up5 ай бұрын
Please don't be mad_t about my clickbait titles :D
@bubach854 ай бұрын
FYI: This guy has no idea what an RTOS is. Nothing he said about it is true. 🤣
@cheesed_up4 ай бұрын
Thanks for the feedback! May I ask what makes you say that? I don't want to spread misinformation and am happy to listen to what you have to say!
@idesys31355 ай бұрын
Now do it in rust
@romsthe6 ай бұрын
Did you not get my comment about not running your task inside an ISR, or do you keep deleting it ? if it's a bug from youtube ok, but if you'd rather hide it rather than learn something then it's bad. Good devs learn from their mistakes and from colleagues, refusing knowledge won't get you far. Also don't hide knowledge to others, I think it's as bad as a crime, sincerely
@joshnjoshgaming6 ай бұрын
Did it contain a link? often links get shadow-banned by youtube
@romsthe5 ай бұрын
@@joshnjoshgaming well I tried again but it won't show up. If you want look for "context switch" and not running code inside the ISR. You can also check interrupt code for storing and retrieving the context for each arch in free RTOS for examples
@romsthe5 ай бұрын
@@joshnjoshgaming actually there's an excellent series of videos about this if you look for "element14 introduction to RTOS" on youtube
@cheesed_up5 ай бұрын
Hey @romsthe, sorry that your comment dissapeared. And yeah, I'm pretty sure that @joshnjoshgaming is right - youtube probably hides comments with links. I also can't put links into video description without youtube complaining.