Piccolo OS: Write Your Own Multitasking OS

  Переглядів 19,699

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
@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".
@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!
@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 Місяць тому
What do you mean with "why him"?
@ajrhodes3262
@ajrhodes3262 3 роки тому
Great video, Gary!! I had no idea anyone could pull this off with a little microcontroller!!
@Quarky_
@Quarky_ 3 роки тому
Amazing deep dive! Thanks so much Gary!
@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.
@GabrielDubatti
@GabrielDubatti 3 роки тому
Congrats for 200K SUBS !!
@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...
@esra_erimez
@esra_erimez Рік тому
This is fantastic. I can't thank you enough for this wonderful video and excellent OS.
@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; )
@electrotsmishar
@electrotsmishar 2 роки тому
Thank you. Phenomenal job
@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? :)
@HisVirusness
@HisVirusness 3 роки тому
Thank you for this.
@PATRIK67KALLBACK
@PATRIK67KALLBACK 3 роки тому
Nice work!
@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...
@montpierce424
@montpierce424 2 роки тому
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 !!
@1MarkKeller
@1MarkKeller 2 роки тому
*GARY!!!* Good night Professor! Good night fellow classmates! Stay safe out there!
@GaryExplains
@GaryExplains 2 роки тому
MARK!!!
@Basheski
@Basheski 3 роки тому
Btw, side question - what font is that?
@abpccpba
@abpccpba 3 роки тому
Gary, have you ever looked into Forth Programing Language? It is older than C.
@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.
@valitocardoso4643
@valitocardoso4643 3 роки тому
I wish you were my University Teacher! 👍👍
@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...) ;-))
@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: ukposts.info/have/v-deo/n2GHeoB_oYKHrok.html
@FarrellMcGovern
@FarrellMcGovern 3 роки тому
Interesting...personally, I would use a multitasking version of FORTH, but hey, RPN rocks. :-)
@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.
@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.
@DavidCabanis
@DavidCabanis 3 роки тому
Hi Gary, I am very impressed with the depth of your videos this is very unusual for UKposts. 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!
@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!
@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
@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.
@piiumlkj6497
@piiumlkj6497 3 роки тому
This is what going hardcore looks like
@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_ .
@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.
@kruzerblade4740
@kruzerblade4740 3 роки тому
Kamiccolo -Goku
@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."
@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...
@grzegorzbrzenczyszczykiewi2948
@grzegorzbrzenczyszczykiewi2948 3 роки тому
Will there be speed test g between Rog Phone 5 and IPhone 12 ?
@monochrome_linux
@monochrome_linux 3 роки тому
Haven't clicked this fast 🤣. 1 minute ago
@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 🤣
@realme-em3xy
@realme-em3xy 3 роки тому
Top
@shuhabbasheer3621
@shuhabbasheer3621 3 роки тому
Omg 🤐
@amitezuthachan5779
@amitezuthachan5779 3 роки тому
DBZ fan?
@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 ?
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level Learning
Переглядів 326 тис.
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Переглядів 578 тис.
🍕Спидран по Новостям #shorts
00:37
King jr
Переглядів 2,9 млн
How I learnt to think like a MATH GENIUS (and so can you)
7:47
Python Programmer
Переглядів 3,5 тис.
NTFS vs FAT32 vs exFAT - Everything You Need To Know
14:16
Gary Explains
Переглядів 106 тис.
A CPU With Just One Instruction!!!
14:33
Gary Explains
Переглядів 187 тис.
Why Linus Torvalds doesn't use Ubuntu or Debian
2:43
TFiR
Переглядів 4,2 млн
Write Your Own Emulator for Your Own CPU - Using a Raspberry Pi Pico
32:17
This keyboard is a $100 computer!!! - Raspberry Pi 400
15:23
ShortCircuit
Переглядів 1,9 млн
#372 How to use the two Cores of the Pi Pico? And how fast are Interrupts?
14:25
I Can Save You Money! - Raspberry Pi Alternatives
15:04
Linus Tech Tips
Переглядів 3,1 млн
Making an OS (x86) Chapter 1 - CPU, Assembly, Booting
6:56
Daedalus Community
Переглядів 434 тис.