Piccolo OS: Write Your Own Multitasking OS

  Рет қаралды 20,035

Gary Explains

Gary Explains

3 жыл бұрын

Piccolo OS is a small multitasking OS for the Raspberry Pi Pico. It is designed primarily as a teaching tool. It demonstrates the fundamentals of a co-operative multitasking OS and the Arm Cortex-M0+.
GitHub: github.com/garyexplains/picco...
Introduction to Android app development: www.dgitacademy.com
Let Me Explain T-shirt: teespring.com/gary-explains-l...
Twitter: / garyexplains
Instagram: / garyexplains
#garyexplains

Пікірлер: 89
@stanleyyyyyyyyyyy
@stanleyyyyyyyyyyy 3 жыл бұрын
Gary - thanks for the code! I checked it and it looks exactly how it should look like - simple, short, clean and self explanatory. Very nice!
@jamesgoacher1606
@jamesgoacher1606 3 жыл бұрын
This reminds me of the entry in Dr Dobbs Magazine in the late 70s (probably) that when Mr Punch (Punch was a Satire type magazine of the same period) was asked for his advice on writing a C-compiler. "Don't".
@Quarky_
@Quarky_ 3 жыл бұрын
Amazing deep dive! Thanks so much Gary!
@ajrhodes3262
@ajrhodes3262 3 жыл бұрын
Great video, Gary!! I had no idea anyone could pull this off with a little microcontroller!!
@GabrielDubatti
@GabrielDubatti 3 жыл бұрын
Congrats for 200K SUBS !!
@esra_erimez
@esra_erimez Жыл бұрын
This is fantastic. I can't thank you enough for this wonderful video and excellent OS.
@alliejr
@alliejr 3 жыл бұрын
Ahhhhh. Takes me right back to my operating systems class at university in 1985. The entire semester was spent building “Minix”. Less than 10 years later I start hearing about Linus and still don’t understand “why him”...???
@mitlanderson
@mitlanderson Жыл бұрын
Why him? What's the meaning behind this question? Curious.
@godnyx117
@godnyx117 3 ай бұрын
What do you mean with "why him"?
@keithstandiford3761
@keithstandiford3761 Жыл бұрын
Gary - Thanks for motivating me to read the ARM documents! I wrote this for M68010's in the 80's and it is just what I wanted for my Pico projects. BTW, I think you may want to run thread mode as privileged: it fixes USB Stdio and maybe more...
@vapourmile
@vapourmile 3 жыл бұрын
You wrote this? Impressed. I can recall a conversation we had in DMs when you asked me why I was asking all sorts of bizarre questions about the Raspberry Pi and I explained it was "What about people who want to write their own OS?". I can't help but wonder if that exchange lit the spark which led to this video? :)
@electrotsmishar
@electrotsmishar 2 жыл бұрын
Thank you. Phenomenal job
@PerchEagle
@PerchEagle 3 жыл бұрын
Yep, I'm happy that I found some of the ideas I've thinking of to call sequence of functions to run in multitasking system. But I couldn't call the functions directly, so I thought of taking the address of each function and call that function by address in the multitasking manager. And manager the to_run_task and queue_task by locks.
@PATRIK67KALLBACK
@PATRIK67KALLBACK 3 жыл бұрын
Nice work!
@HisVirusness
@HisVirusness 3 жыл бұрын
Thank you for this.
@marklewus5468
@marklewus5468 3 жыл бұрын
Very nice. If you continue development it would be great to have a function that allows you to permanently end a task...
@Chalisque
@Chalisque 3 жыл бұрын
Random thing about C. I never knew you could put the typedef _after_ the struct (as in struct { ... } typedef mytype; as opposed to typedef struct { ... } mytype; )
@IBITZEE
@IBITZEE 3 жыл бұрын
thanks for the hint... after this video... I'm already writin' the PicolloWUM--- a fantastic OS... will run on R-PI Zero,,, and can use any Windows/Unix/Mac program... (PS: don't wait for me... this can take a while...) ;-))
@valitocardoso4643
@valitocardoso4643 3 жыл бұрын
I wish you were my University Teacher! 👍👍
@1MarkKeller
@1MarkKeller 3 жыл бұрын
*GARY!!!* Good night Professor! Good night fellow classmates! Stay safe out there!
@GaryExplains
@GaryExplains 3 жыл бұрын
MARK!!!
@John.0z
@John.0z 3 жыл бұрын
A very interesting project Gary. Thank you. Have you considered a version of Piccolo to run on the rest of the Raspberry Pi range? I have several of them, with the Pi4 as my test machine, and no need for a Pico. But I would like to go through the process of learning and building a simple OS. Yes, I know that there are several Linux distros that allow you to roll-your-own. But by the time you get to even a small modern Linux, things are very complex for a beginner. Also, Piccolo could well become the next Minix, and so find a place in most universities.
@saassas5879
@saassas5879 2 жыл бұрын
Check out xv6 - it’s a similar concept to this one but that runs entirely within an emulator, relatively easy to get it up and running in qemu. It’s a relatively simple OS meant to be used as an educational tool, it’s what we did a lot of work in for an OS course I took in college. It does come as a “complete” OS, but there’s plenty of relatively well-written code to parse as well as plenty of functionality to add on your own.
@John.0z
@John.0z 2 жыл бұрын
@@saassas5879 I was looking and wondering if that OS was interesting - then I saw the reference to John Lions. What a wonderful, inspiring man. I knew him for a few years when I first started working at UNSW. Seeing that John's book is a point of inspiration for Xv6 does increase my interest in it! Thank you.
@montpierce424
@montpierce424 3 жыл бұрын
Great video Gary. I'm really looking forward to getting this going. I'm using vscode on windows. When compiling I get the following error: [build] D:\Dev\Pico\c-projects\piccolo_os_v1\context_switch.s:163: Error: SVC is not permitted on this architecture Is that an issue with the toolchain I'm using? Any suggestions for vscode on windows environment? Thanks !!
@FarrellMcGovern
@FarrellMcGovern 3 жыл бұрын
Interesting...personally, I would use a multitasking version of FORTH, but hey, RPN rocks. :-)
@abpccpba
@abpccpba 3 жыл бұрын
Gary, have you ever looked into Forth Programing Language? It is older than C.
@Basheski
@Basheski 3 жыл бұрын
Btw, side question - what font is that?
@sabriath
@sabriath 3 жыл бұрын
So you are requiring the task to give back control occasionally to the OS handler? Is there a timer interrupt for the Pi that you could use to force threads to give up their time slot for the next in the list? It seems simple enough to make it multi-core functionality.
@GaryExplains
@GaryExplains 3 жыл бұрын
I cover that in the readme.
@kaz42
@kaz42 3 жыл бұрын
Not that simple. You will need synchronization primitives as well. In a non-preemptive OS, your code won’t be interrupted, so no synchronization is really needed.
@sabriath
@sabriath 3 жыл бұрын
@@kaz42 What? I mean, I see you said some words, but none of what you said makes any sense together like that....especially not as a reply to what I've said.
@GaryExplains
@GaryExplains 3 жыл бұрын
@@kaz42 You can have preemptive multitasking without mutexs etc, one isn't a prerequisite of the other. However mutexs etc do help with interprocess communication, and synchronization. I have a preemptive version of Piccolo OS working on a BluePill without mutexs.
@kaz42
@kaz42 3 жыл бұрын
@@GaryExplains if you share nothing between threads or disable timer interrupts inside critical sections, you can. Each has their own advantages and disadvantages. Although we only have 264kb of RAM, dynamic memory management is still possible, but with share nothing concept, it would be rather inflexible.
@paulwratt
@paulwratt Жыл бұрын
Did you ever get a V2 (pre-emptive OS) off the ground? FWIW the AtariST MiNT Kernel is also cooperative multitasking
@GaryExplains
@GaryExplains Жыл бұрын
Adding Preemptive Multitasking to Piccolo OS for the Raspberry Pi Pico: kzfaq.info/get/bejne/nZeGea15z7K6fYk.html
@DavidCabanis
@DavidCabanis 3 жыл бұрын
Hi Gary, I am very impressed with the depth of your videos this is very unusual for KZfaq. I have been playing with the code on your repo. when making your piccolo project I get an error with the assembler around the use of the instruction SVC #0x00 . I know that the SCV instructions is optionally implemented in some of the Cortex-M0+ (synthesis option) consequently the arm_none_eabi_gcc has to target options one including the SVC instruction: -march=armv6s-m and one without it: -march=armv6-m. As far as I can see the makefile uses -march=armv6-m by default thereby causing the fault: "context_switch.s:163: Error: SVC is not permitted on this architecture". Are you using specific cmake arguments used to overwrite this?
@GaryExplains
@GaryExplains 3 жыл бұрын
Do you have the Pico C/C+ SDK installed and working?
@DavidCabanis
@DavidCabanis 3 жыл бұрын
@@GaryExplains Yes I am able to compile and run the standard examples command-line and VSCode. The only issue that I have had so far is this assembly file provided by piccolo OS. If I comment out the SVC instruction inside the code I can assemble and link with the rest of the object in the project.
@GaryExplains
@GaryExplains 3 жыл бұрын
@@DavidCabanis Hmmm, that is odd. Works for me using what I uploaded to GitHub.
@GaryExplains
@GaryExplains 3 жыл бұрын
@@DavidCabanis Do you have a Raspberry Pi handy? Did you try compiling on it with the Pico SDK installed?
@darthandre11
@darthandre11 3 жыл бұрын
Yup, i got the same problem while running "make" -> Error: SVC is not permitted on this architecture. And yes, my SDK is working with the raspberry doc examples. I hope it has a solution since Gary's work here is awesome, I really want to try it!
@cthoadmin7458
@cthoadmin7458 Жыл бұрын
A newbie question: In the collaborative model described, what happens if a process never calls piccolo_yield? Because it dies for some reason? Does that mean we have a zombie process, whose very existence means it never yields control and the whole shebang crashes?
@GaryExplains
@GaryExplains Жыл бұрын
Yes, it never yields and the whole system fails.
@RPG_ash
@RPG_ash 3 жыл бұрын
Favourite drink: JD. Not sure it's a good idea to drink and code though.
@MatthewHarrold
@MatthewHarrold 3 жыл бұрын
Wild Turkey and Cola in the left hand, Coopers Red (Australia) in the right hand, ready to go.
@32_bits
@32_bits 3 жыл бұрын
Hi Garry, the RPI Pico is now on supported on Platform IO, check out github.com/Wiz-IO/wizio-pico The flashing LED sketch works with the only requirement is to fit a reset switch to the board.
@meneerjansen00
@meneerjansen00 Жыл бұрын
Does anybody have link to a video or photo's of this OS in action on the Pico? Before I delve into C and understanding how to get this working etc. Can you use a keyboard for input? Or only human input via UART?
@GaryExplains
@GaryExplains Жыл бұрын
Thanks for your interest in Piccolo OS. However I think you might have misunderstood its purpose. This is an OS for a microcontroller (i.e. the Pico). It is not interactive, there is no command line and no need for a keyboard. It is more like an RTOS and not a desktop OS. Of course you could add a command line that could be used over serial or I guess you could add VGA output. But a typical way to use Piccolo OS would be to launch several tasks, one doing the networking, one monitoring some sensors, one writing to the storage, etc. All for an embedder / maker project.
@meneerjansen00
@meneerjansen00 Жыл бұрын
@@GaryExplains Thank you for clearing that up! I get it now. Succes s with your project. The Pico is affordable, and more important, available at the moment!
@piiumlkj6497
@piiumlkj6497 3 жыл бұрын
This is what going hardcore looks like
@paulpvhl1930
@paulpvhl1930 3 жыл бұрын
Haven't got the Pico yet so I can't experiment yet, but how do you use both CPUs?
@GaryExplains
@GaryExplains 3 жыл бұрын
I cover using both CPUs in my Pico C/C++ video.
@paulpvhl1930
@paulpvhl1930 3 жыл бұрын
@@GaryExplains I'll take a look at that. Thanks. First time I wrote machine language was for a PDP12 about 50 years ago, but haven't for over 30 years. I'm looking forward to learning it again but with assembler and hopefully Rust some day. Your videos are helpful.
@paulwratt
@paulwratt Жыл бұрын
@@paulpvhl1930 just in the last month (Sept 2022) there have been a couple of videos on YT about Bare Metal Rust on the Pico
@PihkalTheTihkal
@PihkalTheTihkal 3 жыл бұрын
Isn"t this basically how one would handle ISR's in x86 assembly?
@GaryExplains
@GaryExplains 3 жыл бұрын
All interrupts are basically the same across modern CPUs. However the details vary.
@PihkalTheTihkal
@PihkalTheTihkal 3 жыл бұрын
@@GaryExplains I have zero knowledge about how the M0 handles context switching, but judging by the way you explain all of it, it really reminds me of when I, back in the days, would write ISR's used by TSR programs in x86 assembly. The whole "context switching" concept, to me, sounds like jumping in and out of ISR's. But what do I know, I haven't coded assembly in over 20 years. Nevertheless I really enjoyed the "deep dive" into the concept and the code, please keep 'em coming! Thanks!
@paulwratt
@paulwratt Жыл бұрын
@@PihkalTheTihkal You are right. In the modern context, using TSR's is basically multi-tasking "task" for a _single tasking OS_ .
@kruzerblade4740
@kruzerblade4740 3 жыл бұрын
Kamiccolo -Goku
@ChesterFoster
@ChesterFoster 3 жыл бұрын
Why is this video not in 1440P 😔
@GaryExplains
@GaryExplains 3 жыл бұрын
Why should it be? I don't see the point.
@nikhilmwarrier7948
@nikhilmwarrier7948 3 жыл бұрын
This video focuses on a different sort of quality...
@monochrome_linux
@monochrome_linux 3 жыл бұрын
Haven't clicked this fast 🤣. 1 minute ago
@grzegorzbrzenczyszczykiewi2948
@grzegorzbrzenczyszczykiewi2948 3 жыл бұрын
Will there be speed test g between Rog Phone 5 and IPhone 12 ?
@danielquintero7725
@danielquintero7725 2 жыл бұрын
Y preventivo?
@GaryExplains
@GaryExplains 2 жыл бұрын
As I say in the documentation, " I have ported the same code to an STM32 BluePill with a Cortex-M3 and pre-emptive tasking works via SysTick/PendSV."
@realme-em3xy
@realme-em3xy 3 жыл бұрын
Top
@nialltracey2599
@nialltracey2599 Жыл бұрын
Why not "PiccolOS"...?
@GaryExplains
@GaryExplains Жыл бұрын
Why not Piccolo OS?
@nialltracey2599
@nialltracey2599 Жыл бұрын
@@GaryExplains Tradition dictates that if you can make a computer technology confusingly unpronounceable, you must do so! 😁😁
@GaryExplains
@GaryExplains Жыл бұрын
@@nialltracey2599 🤣
@amitezuthachan5779
@amitezuthachan5779 3 жыл бұрын
DBZ fan?
@shuhabbasheer3621
@shuhabbasheer3621 3 жыл бұрын
Omg 🤐
@benfubbs2432
@benfubbs2432 3 жыл бұрын
I haven't watched this yet, but if I haven't written the Windows 11 by morning after watching this I am unsubscribing.
@GaryExplains
@GaryExplains 3 жыл бұрын
😂
@bakamarimo7528
@bakamarimo7528 3 жыл бұрын
Bruh you'll write macos
@swaggitypigfig8413
@swaggitypigfig8413 3 жыл бұрын
Lul
@Basheski
@Basheski 3 жыл бұрын
🤣✌
@Winnetou17
@Winnetou17 3 жыл бұрын
@Ben Fubbs You are joking, right ? It's impossible, even as a proof of concept, to have Windows 11 so quick. Do you know how much effort is to track everything and send it home to Microsoft ?
Piccolo OS: What is Context Switching?
17:56
Gary Explains
Рет қаралды 23 М.
GeckOS: a Unix-like 6502 operating system | VCFMW 2019
50:29
VCF Midwest
Рет қаралды 81 М.
🌊Насколько Глубокий Океан ? #shorts
00:42
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 23 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 123 МЛН
IBM Skillsbuild || FEWD Internship || Orientation
1:48:46
CSRBOX
Рет қаралды 13 М.
EVERYONE Needs to Learn a Little Bit of AWK!
16:29
Gary Explains
Рет қаралды 395 М.
Reading Silicon: How to Reverse Engineer Integrated Circuits
31:52
The Making of Linux: The World's First Open-Source Operating System
11:33
ForrestKnight
Рет қаралды 1,2 МЛН
A CPU With Just One Instruction!!!
14:33
Gary Explains
Рет қаралды 188 М.
When Did Raspberry Pi become the villain?
21:54
Jeff Geerling
Рет қаралды 1,4 МЛН
How does an OS boot? //Source Dive// 001
50:22
Low Byte Productions
Рет қаралды 389 М.
How Machine Language Works
19:48
The 8-Bit Guy
Рет қаралды 942 М.
🌊Насколько Глубокий Океан ? #shorts
00:42