Это видео недоступно.
Сожалеем об этом.
Piccolo OS: What is Context Switching?
HTML-код
- Опубликовано: 3 мар 2021
- I am having fun with my Raspberry Pi Pico, and I thought I would put together a small multitasking OS for the Pico, which I have called Piccolo OS. This first video covers the idea of Context Switching, a key concept for any multitasking OS.
How does a CPU work? • How does a CPU work?
Multitasking vs Multithreading vs Multiprocessing • Multitasking vs Multit...
Introduction to Android app development: www.dgitacadem...
Let Me Explain T-shirt: teespring.com/...
Twitter: / garyexplains
Instagram: / garyexplains
#garyexplains
Your ability to explain hard concepts is unique , thanks !
An actual stack exchange. Cool.
Ok I am going to play the Multitasking video in the background while I watch this one!
I see what you did there! 😂
Look forward to this series Gary and congrats on 200K subs.
Thanks 👍
Hey Gary! I'm trying to write some code similar to what you did with the piccolo_yield(...) function by running a svc interrupt. I'm getting an error from the assembler "SVC not supported on this architecture." Any tips? Thanks!
Good video, nice explanation. I look forward to seeing what the code looks like.
Just one nit (at least for now); if "task1_func" is the entry point for the main function of task 1, then there is no need to take its address when passing it to the "piccolo_create_task()" function. The compiler does the right thing without complaint, I realize, but you can simply use "piccolo_create_task(task1_func)". If "task1_func" is a struct that contains task information, such as the actual entry point address, the address and size of the thread stack, and perhaps initial parameters, then the '&" is appropriate.
I have a small multi-tasking real-time executive that I wrote for ARM Cortex-M that does have thread priorities, timers, counting semaphores, gates, mutex, and events, and I'm attempting to implement signal handling in thread context as an option. It provides limited thread-local-storage to allow newlib nano that comes with the toolchain provided by the FPGA vendor (Microchip) to work in multiple threads without interference for the most part. I have my kernel working on M3, M4, M4F, and M7 (with double precision), and have put it on the embedded hard core in a SmartFusion2 FPGA as well as on several flavors of STM32.
What I would really like to see is something that explains how to write an os-aware plug-in or scripts for GCC/OCD, Eclipse, VS Code, or some other debugger or IDE.
I am not going to argue coding style with you, but without the & you are relying on an implicit conversion, which does have its merits, however for lesser known use cases, like function pointers, then I personally I like to use the &. The purpose of this video (and the following videos) is not for nit picking coding style. It is for teaching some OS fundamentals. Nit picking just makes me hesitant to publish the code because there is an army of pedants waiting to pounce on every & and *.
awesome beginners explanation of concurrency.
This is quite an advanced topic. I'm writing an exokernels, the bare minimum runs in kernel mode, like almost nothing. In fact I think the only thing that needs to run in kernel space is a process swap. I might even do a default kernel function for the ISR that can dispatch a signal to a process in user space.
I thought it would be way harder with a lot of hacks, but this looks really nice!
As a Electrical Engineer that worked on early CPUs...I thank you for a better understanding of threading and multitasking. Keep up the good work!
Wow. What do you think of the RISC-V stuff? The arm assembly to push and pop the stack is pretty convenient and RISC-V doesn't have this...
@@kayakMike1000 Each has its specialized use. The reason both are still in use today. I learned on the stacks but its sometimes very easy to get things lost. It is amazing that simple call programs and loops work better than complex ones. Especially now we have much faster CPUs and less latency in memories...about a wash either way you go.🤔
It looks like the pico has the processing power and memory of a micro computer from the 1980's so it might be quite good to see an OS embedded into the pico thats similar to a C64 or zx spectrum built in with a high level programming language, text editor, access to hardware and memory locations, but then there needs to be a graphics chip.
The Pico has a 2nd processing core that could be used for graphics.... 🤔
@@sjenkinsnm This. But also even using only one core, the Pico has this thing called PIOs that can handle the time critical part of outputing video, the core just need to write a frame buffer and then DMA and PIO can output it, leaving free the core to other stuff.
Nevermind the 80's. I remember single core processors in the 90's, and RAM speeds only got around 300 mhz at the end of the 90's. If you wanted a dual core back then you had to buy a motherboard with dual cpu sockets.
@@sjenkinsnm Gary never used the second core in his piccolo OS. I know why, because it would make piccolo OS that much harder to develop. Plus his examples didn't need another physical core.
@@sgodsell2 That's why the 2nd core can be used for graphics :) ZX80/81 powered the display by software in the beginning of the 80's.
Great job Gary. Next you will have to add in more code to use the second core. I know that will be a lot harder to add in multiple cores. I wish the Pico's came with double the RAM and storage, but then we would be looking at a ESP32. I really hope the pi foundation looks at making some future Pico's with more RAM, storage, faster clock speeds, and even more cores. If they did that, then I would drop all the other micro controllers that I currently have in my arsenal.
I show how to use the second core in my previous Pico video, but to be honest I doubt I will have time to add multitasking to the second core.
I programmed my Teensy 4 with thread handling built into the Arduino library. It is a very handy library, it even exploits software delay that CPU does nothing to switch context for other threads, achieving high performance multitasking.
Very educational.
I think the Pi Foundation is actually working on an RTOS for the Pico, so it will be interesting to see when and what they'll produce.
Lets hope it is industrial tron compliant.
"Old chat... I'd say... you were astonished when that interrupt occurred!!!" ;-)
i just wonder how do you even understand all these and then explain it nicely.... Appreaciated ;-)
Great little simple os Gary!
Good job and thanks for the Assembly memory jogger -- long time; no see.
(need my IBM Green Card)
wow grate video you have me thicking about making an OS now if only i had time to do projects like this.
Please do a video on custom kernel
Congrats on 200k.
I realy enjoy your work Gary, Thank you for this video (and others). For the sake of completeness, I would like to clarify that at reset you are in thread mode using MSP. The choice of PSP has to be done manually via CONTROL and its configuration is also manual unlike the value of MSP that is automatically fetched from address 0x0 at reset. Additionally it might be worth mentioning the return address is automatically calculated by the core at the time of the exception and stacked along with the current value of LR during the context saving. I expect you are using the systick timer for your context switch signal. do you make use of pendsv too?
I think I mention most of that (see 9:55 and 10:55 and note "if you desire") but not in so much detail as that is getting into the nitty gritty which we will when we start looking at the code.
Hey Gary, may you document your progress also on GitHub?
It is actually all done. Just making the video is all that is left to do.
@@GaryExplains Great, I will be checking it out! Many thanks for your efforts.
What about releasing sources, Garry? Nice job by the way!
What about it? I will upload the source with the next video.
@@GaryExplains great thanks!
But does this also mean that every process runs on different cores, or is the example you gave only running on 1 core?
1 core.
I'm working on an x86-64 OS for my bachelor project. Now either ARM is significantly simpler to deal with from a kernel perspective, or Gary simplified quite a bit, haha. If it's the former I'm jealous
If you watch the next video you can see my implementation and the source code is on GitHub. Why did you pick x86-64, don't you see the direction the market is going?
I understand that you're doing this as a teaching series but you might be interested to know (if you don't already) that FreeRTOS works with the Pico C SDK.
If you install the "smp" branch of the FreeRTOS-Kernel submodule then it does multi-tasking across both cores too.
Thanks for sharing. Very cool stuff. Have you measured the time it takes to switch tasks ?
Aptly explained.
Hi Gary, looking at your video I began to think differently about a problem I'm having, which is a Windows application that shows UI freezing under Windows 10, but not under Windows 7. Instead of looing at the application-code, maybe I should look at how Windows deals with input from the keyboard and mouse to interrupt running application threads. Are you aware of any differences that might exists between Windows 7 and 10 in dealing with user input?
Cool. Subscribed.
What is the link to GitHub can't find in description
Try github.com/garyexplains which incidentally is the first result on Google if you search for "Gary Explains GitHub"
Hi - Great videos! I would love to explore your Piccolo OS on PiPico - however I can't seem to find the code in your github (yet?). I went to /examples/Raspberry Pi Pico/Piccolo_OS/ but there was only the design document there. Hopefully you will be uploading the companion code soon...
Yeah, no code up yet, still tweaking it, correcting spelling mistakes, double checking everything, etc. The code will go up soon, some time next week I guess.
Piccolosan!!
🤣
Program is set of instructions that all of them are making somethings on some registers - rather than "program is just set of registers"
Obviously that was a big typo, should be "CPU" not "program".
How do you use the debug pins? Do you b have a video for that?
No video, sorry, but there are very clear instructions in Chapter 5 of the Getting started with Raspberry Pi Pico document. See www.raspberrypi.org/documentation/rp2040/getting-started/
@@GaryExplains thanks
i bet piccolo OS is made by Namekian 🤣🤣😂😂😂
But we can't understand their language 😂
Request a RUclips video, #Pico with ARM assembly programming, with GitHub code, compile-linking with debugger.
Like the C/C++ posted (5 ✨ 🌟)
So it is just a simple version of RTOS ?
I don't know what you mean by "just", but yes this is a very simple RTOS with severe limitations and lots of missing functionality. However, as a teaching tool I hope it is useful. This is "Gary Explains", not "Gary Develops a Commercial RTOS" 😜
Any git repo one could take a look at?
Just a readme in my GitHub at the moment: github.com/garyexplains/examples/tree/master/Raspberry%20Pi%20Pico/Piccolo_OS
Should be named PiccolOS
next: Gohan OS
So Where is the DragonBall?
Nice title! Very clickable!
No stack overflowing this time....🤣⛔
This is definitely something I need, but don't want to understand.
where's the source?
There is no source for a video about context switching. When I do the video about Piccolo OS itself there will be some source code.
Don't ever say that word "let me explain " it's disgusting 😡😡😡😡😡😡😤😤
Eh?
1:13 - 1:21 "Concurrent describes things that are occurring, or people who are doing something, at the same time, such as 'concurrent users' of a computer program. Consecutive refers to things that are arranged or happen in a sequential order." Parallel is equivalent to concurrent in this context. Concurrent computing uses multiple CPUs; the Pico has two. So now, part way in, I'm confused as to what you're addressing! Keep up the good work Gary. I'm sure the rest of the video will be up to your usual standards and I'll catch on -- or?
Concurrent and parallel are not technically the same in this context. Also, although the Pico has 2 CPUs, here I am ignoring the 2nd CPU core.
@@GaryExplains My point was it isn't concurrent or parallel, it is consecutive, one task after the other. Thanks for the reply.
@@paulpvhl1930 OK, well without watching the video again, I don't remember in what context I used the word consecutive. Let me look at the clip you noted.
@@paulpvhl1930 So I looked at the clip at the time code you mentioned and I don't use the word consecutive.
@@paulpvhl1930 Also it isn't one task after the other. That would mean you start task A, complete task A and then start task B, complete task B etc. In concurrent execution A and B don't complete and the start/stop of one task isn't dependent on the other. In consecutive executive task A must finish before task B starts.
2040 playing crisis in Piccolo OS