*My takeaways:* 1. Multitasking on a single-core CPU - CPU time is divided for different programs, and program executions are switched instead of being executed one after another, but there is no real speed improvement 0:36 2. Multithreading on a single-core CPU - Codes in the same program were executed in "parallel", and threads are switched instead of being executed one after another, but there is no real speed improvement 2:59 3. Multiprocessing - this is when we have more than one CPU core, and we can do real multitasking and multithreading (i.e. executing programs and threads on different cores at the same time) 4:18 4. An experiment on Raspberry Pi with a single-core CPU 4:55 5. An experiment on Raspberry Pi with a quad-core CPU 7:23
@ironcladruffian14903 жыл бұрын
Thanks for the time stamps. There is an important concept of Io bound and cpu programs that are not mentioned here. If your program is Io bound, running multi threading can help make it run faster.
@leixun3 жыл бұрын
@@ironcladruffian1490 that’s right and important!
@UnknownSend3r3 жыл бұрын
@@leixun when a multi-threaded programme on a multi-processing CPU is taking up 100% of all cores, how are other programmes that are essential to running the computer functioning ?
@CARPB1473 жыл бұрын
@@UnknownSend3r - They get a slice of time as they need. That is why your multithreaded programme does not run 100% of all cores continuously *all the time* it is running.
@UnknownSend3r3 жыл бұрын
@@CARPB147 thanks for the answer, as it's been a while.but another quick question i have is, if that happens like I described earlier does that drastically slow the computer down.
@TheSar6 жыл бұрын
Another fabulous representation of a complex concept. The lab test you used to explains this was superb - well done Sir!
@nimrodlevy6 жыл бұрын
Please do video on multitasking!!! Many Many thanks in advance!!
@achakraborti6 жыл бұрын
I'd love to see such a video.
@galenblack69216 жыл бұрын
Gary, I have been trying to explain this, for years, to people that know nothing of multitasking. You explained it perfectly. Thankyou.
@VeselinMarkovic6 жыл бұрын
Excellent as always - clear, short and simple. Hyperthreading next? I reckon most people think that a processor with hyperthreading is twice as fast as one without it, which isn't true; it's more efficient, yes - but not twice as much. A video on RT systems would be quite interesting. Keep making excellent vids, Mr Sims! 👍
@senthilanantha13 жыл бұрын
Your explanation was simple, straight forward, practical and very effective. 👍
@fuzz335946 жыл бұрын
Professor Sims - brilliant clarity as one comes to expect from the Chair of the Department.
@bkdev8866 жыл бұрын
I like how Gary will try to explain with practical example , it needs dedication.
@SamerTabbal6 жыл бұрын
So a CPU can have Multi-Cores, each Core can Multi-Task, and each Task can Multi-Thread.
@sarhadchoudhary8483 жыл бұрын
Processception.
@rohankandi99002 жыл бұрын
Not exactly. Each core CAN ONLY RUN A SINGLE TASK at any given point of time; however it gives the illusion of MULTITASKING BY SWITCHING between threads after certain amount of time.
@greatwavefan3972 жыл бұрын
@@rohankandi9900 Just like people
@agmg3059 Жыл бұрын
@@rohankandi9900 not exactly right i had disabled cores on my ryzen and used to launch chrome youtube while opening windows music player and playing music so i was doing 2 programs 2 task only one one core without other cores and smt it was slow tho but still was doing the job fine
@GumbieUsaGames Жыл бұрын
@@agmg3059 try dong the same with a heavy program... the above listed will context switch very fast and give an illusion of multitasking. IMO
@venkataravieluri96256 жыл бұрын
Really looking forward for your dedicated video on multitasking.
@alvaroj95093 жыл бұрын
This was so good Gary bro, especially the visual explanation with raspberry pi. Thank you so much!
@sarenodev2 жыл бұрын
This video alone asnswers a lot of my years old question. The explanation is excellent.
@BrendanGeels6 жыл бұрын
Excellent video! I agree with Mr. Marković below, a video on RT systems or just RT OS's would be great!
@tudorhategan3770 Жыл бұрын
Can't find a better explanation. GREAT ONE!!
@GaryExplains Жыл бұрын
Glad you liked it!
@moy25495 жыл бұрын
Ive literally been trying to wrap my head around this concept for 2 weeks now and you managed to clear things up int 10min. Thanks for this great video!!!!
@Shrisamarth26016 жыл бұрын
Gary The guru of technology 👍🏻
@1MarkKeller6 жыл бұрын
Guru of Tech. Hmmm ... not bad!
@jayde7444 жыл бұрын
Thanks for let us understand Multithreading. Because we had a little twist there.
@mockingjayu22102 жыл бұрын
Thanks gary for that super neat demo :)
@alenkruth6 жыл бұрын
Nice video Sir! Keep'em coming 😀😀😀
@MuhammadAhmed-wh5kv6 жыл бұрын
What a great demo Gary ..
@saurabhjha5754 жыл бұрын
thanks for making it understand in a simpler way
@subhoghosal74 жыл бұрын
Waiting for a multitasking video. It seem interesting. OS remain always a nightmare to me, but you explain so clearly. Looking for the above mentioned video.
@tanmoypaul13625 жыл бұрын
A video discussing multitasking in detail would be most welcome!
@ashfaqrahman27956 жыл бұрын
You can't be so good at explaining things with such cute looks. God bless Gary.
@SivicIsntFat3 жыл бұрын
Gary you are exactly why the internet is so awesome and important!
@gakwayadavid15586 жыл бұрын
Explicitly explained!👐
@DavidDeLuge6 жыл бұрын
Beautifully demonstrated.
@swadhikarc78585 жыл бұрын
Excellent explanation. Finally gotto understand this obscure topic
@danielc42672 жыл бұрын
This is awesome! I love the demo at the end. Thank you
@ankit_aanand6 жыл бұрын
Thank you 😊 sir for making video on this topic !!!
@Benny39394 жыл бұрын
Really great video for explaining multithreading vs multiprocessing. Thank you!
@GaryExplains4 жыл бұрын
Glad you enjoyed it!
@harshdevmurari0072 жыл бұрын
Beautifully explained 🙌🏻🙌🏻
@snehithtampa71063 жыл бұрын
Beautifully explained. Thanks sir!
@suyashneelambugg4 жыл бұрын
I think you inferred in summary that when the shared resource is a single core it's multi-tasking as it's time-slicing two appear as multi-processing. Whereas when there are 4 cores, the resources are more and it is actually dividing the resources to run the process and therefore it is multi processing. If i'm wrong then you can explain if there can be a multi-tasking example for quad core using two windows.
@suvetar5 жыл бұрын
Great video Gary, I for one would love to see another video drilling into multitasking, the difference between pre-emptive and co-operative multitasking - but more specifically *how* it happens, I know the task-scheduler runs in a lower ring in modern CPUs, but how did this manage this on old CPUs, how does it stop the operation of one task, save it's state and continue with another? What impact does this have on complicated computations that for example might be in the middle of a complex branch prediction stage? The task scheduler has to save state and presumably do something to the Cpu to stall or complete its instruction pipeline. I think I understand it in a technical fashion but I couldn't explain it to someone, so I'd love your delicate touch on this complex subject! Thanks again for sharing this video :)
@cw59484 жыл бұрын
Best video I’ve seen on the subject!
@Shuvooa4 жыл бұрын
Very Informative video
@tetonicsheldor4 жыл бұрын
Thank you so much for speaking clear English.
@warkingiv1199 Жыл бұрын
Thank you master, good explanation. You helped me a lot.
@jagardina6 жыл бұрын
That was good. When I learned about Unix internals, they didn't talk about multi-threaded much. It was not really a thing at the time. Well done. Would be interested in a tutorial about how Linux does multi-tasking and multi-processing. How does the processor assign tasks to cores, which process is next to run, etc... I know Unix/Linux has a concept of priorities, round-robin fairness algorithms, etc.. Handling the threads on a multi-core processor must be tricky.
@chrisshyi89996 жыл бұрын
Brilliant video!
@darthvader53005 жыл бұрын
I am going to take a refresher course to remember what I have learned in the past. Now I remember again what multithreading is all about. Old age can make one forgetful from time to time. Especially at age 93!
@gilong13113 жыл бұрын
Raspberry pi example helped a lot, thanks!
@TheSulross4 жыл бұрын
In Linux, threads are treated like processes - the distinction being that threads belonging to a given process share the same page mapping tables and permissions on the same set of kernel resources, such as file handles. In some OS, like Windows, the kernel has a more pronounced different treatment (in respect to the data structures associated to these) between a process and a thread - but a process inherently has a least one thread associated to it.
@supersu61386 жыл бұрын
Well Explained sir !!
@aayushmanmishra142510 ай бұрын
Great explanation!!
@KingEbolt6 жыл бұрын
Really Interesting video from you today Professor! Coincidentally when you released this video I was working on learning multithreading in Java with the Thread class. I didn't know it could have such a large effect on performance.
@sydneysights86972 жыл бұрын
Very clear
@momenmostfa82984 жыл бұрын
thank you for your videos it help me a lot with my study as i'm in computer science faculty and i'm studying right now subject calles operating system and your videos are helping a lot so thank you for you effort
@akaappleboy6 жыл бұрын
Great Video Sir!!!!!
@SameerKhan-ht4mx6 жыл бұрын
Really nice demo
@lilmsgs3 жыл бұрын
When I was young in the computer industry, multi-threading was called, parallel processing (multiple processors vs multi-core). Did that term just fade away? AND on a slightly different note: Coding programs for a parallel processing machine was a real chore. How did multi-threading enter into the multi-core world (ostensibly, parallel processing) with apparent, relative ease?
@KatharsasOfficial2 жыл бұрын
I can only draw a picture of the software side of things. Multi-threading specifically refers to using OS-threads inside a single process. And generally it implies using the exact same programming languages that you would use for single-threaded programs, but requires using some additional language features and libraries. I think part of the answer is that writing correct multithreaded code at the lowest possible abstraction level (and even at higher levels) is still really hard. However, quite a bit of abstractions have been created above the actual CPU instructions, memory fences and differences between kernel and user space calls. These low-level things are hidden, but they are the basis of the synchronisation primitives needed by a normal developer writing multi-threaded code. Some examples for the provided abstractions: - Mutexes as an API to effectively lock/unlock sections of code to a single thread at a time, effecitley synchronising access to memory shared by multiple threads - Atomic data types that automatically synchronize any mutation so that data races cannot happen on them - Multithreading-aware datastructures (Hashmaps etc.) that can be used from multiple threads concurrently without issue and hide the necessary synchronization in their implementation - Library functions for creating thread-pools that automatically spin up/down threads as needed based on the amount of load put onto the pool - Ways of easily passing functions and retrieving results to those thread-pools - Various APIs for making error handling easier in the context of concurrent code execution - Frameworks that itself are implemented with multiple threads, but the entry-point for the developer is inside a single threaded context, so the framework user does not have to deal with the underlying multi-threadedness - Libraries hiding parallel execution happening in called library functions from the developer - APIs that allow developers to send data between threads without relying on directly sharing memory between threads (see channels in Go) - The Future/Promise/Async abstraction which allows you to replace direct function results with a promise of a future result in a large-scale way all across any code you write, allowing any called code to actually defer long-running tasks to other threads and then returning immediately to the caller with a promise instead of a result. The caller can then decide to add further code to be executed once the promise is fulfilled, and return with a promise of its own (which includes the additional code having been exexuted). So you can easily define that parts of your code are dependent on the result of a computation without defining the details of when and in which thread your code will actually run. Instead, a library providing an "async executor" runs your code concurrently. And last but not least, there is still simply a lot single-threaded code. Any Javascript or Python program is very likely single-threaded. But a lot of work has gone into making it easier for the developer into actually and correctly writing multi-threaded code, and it is still ongoing.
@pepaokurka38924 жыл бұрын
Really helpful! Thank you :)
@1MarkKeller6 жыл бұрын
*GARY!!!* *Good Morning Professor!!!* *I got a video on/for my birthday!*
@GaryExplains6 жыл бұрын
MARK!!! Happy Birthday
@ZamanSiddiqui6 жыл бұрын
Mark Keller Happy Birthday, Mark. 🎉
@uttamchandra97266 жыл бұрын
Very happy birthday mark!!!! Have a great one!!!!
@1MarkKeller4 жыл бұрын
@@ZamanSiddiqui *ZAMAN SIDDIQUI!* Thanks!
@1MarkKeller4 жыл бұрын
@@uttamchandra9726 *ROBBY CHANDRA!* Thanks!
@shubhamc1833 жыл бұрын
Best explanation ever!!
@GaryExplains3 жыл бұрын
Glad you think so!
@seyedmohammadhosseini57933 жыл бұрын
Great example! Thank U!!!
@raphaelcazenave-leveque799128 күн бұрын
Good explanation
@taher93584 жыл бұрын
Hi Gary thanks for breaking tthese down for lay men like me. Very educationl and a top lad cheers
@prathamovalekar6 жыл бұрын
Real Time Operating Systems please!
@alirezamiri9296 жыл бұрын
Very good video
@AtomFreeFaller Жыл бұрын
Incredible Scenes
@crossthreadaeroindustries85545 жыл бұрын
Great share, good examples.
@natekwezi92423 жыл бұрын
Garry is the 🐐
@albinmaccarthy73676 жыл бұрын
Gary please do a video on multitasking
@TheCreative17984 жыл бұрын
It is sooo good to hear non-hindu guy explaining things in English. THANK YOU SO MUCH!
@arinoba4922 жыл бұрын
So a quad core actually does multiprocessing when you ask for threading, if it can?
@buddhimachamaranga12036 жыл бұрын
good video.
@MarkBekooy6 жыл бұрын
Nicely explained! Still wondering what music is played
@muhammedadiljahfar55126 жыл бұрын
Oh Yeah!! 260th view Prof.Gary is there a particular direction in which the channel is heading bcos I feel it is random but great videos at times
@GaryExplains6 жыл бұрын
What you say random, I say wide. It is all tech based, I won't be being fashion videos or skateboarding videos. It is just tech and tech is big.
@muhammedadiljahfar55126 жыл бұрын
Gary Explains Prof.Gary I didn't mean to insult you or the channel or anything ...I was just wondering...I wholeheartedly love your videos... please don't misunderstand for that was not my intention
@GaryExplains6 жыл бұрын
LOL, no problem, I wasn't insulted. Do you like the "wide" approach, with me covering lots of areas?
@muhammedadiljahfar55126 жыл бұрын
Gary Explains of course...as long there is a Gary Explains video I always watch it
@AlexiGVS6 жыл бұрын
What is better: 6 cores/12 threads? or 8 cores/8 threads?
@wadehelquist3182 Жыл бұрын
AI explains it simply: Imagine you have a big project to work on, like building a Lego city. There are different ways you can approach it to get things done faster and more efficiently. One way is multitasking. It's like doing multiple tasks at the same time. For example, while building the Lego houses, you can also be painting the streets or adding trees. You're working on different parts of the project simultaneously, which saves you time and makes the whole process more efficient. Another way is multithreading. Imagine you have a team of friends helping you build the Lego city. Each friend can focus on a specific task, like one friend building houses, another friend working on the roads, and so on. This way, everyone is working on their own part simultaneously, and the project progresses faster because different tasks are being done at the same time. Lastly, we have multiprocessing. It's like having multiple teams of friends building different parts of the Lego city at the same time. Each team can work on their own section independently, like one team building the houses, another team working on the parks, and so on. This way, the entire city is getting built faster because multiple groups are working on different parts simultaneously. So, to summarize, multitasking is doing multiple tasks at the same time, like working on different parts of a project simultaneously. Multithreading is having a team of friends each focusing on a specific task, making progress faster. Lastly, multiprocessing is like having multiple teams working on different parts of a project simultaneously, speeding up the overall progress.
@NewsSphereNetwork3 жыл бұрын
Helpful, thank you
@aryangurung15573 жыл бұрын
God bless you sir and Thank you
@DonckIT6 жыл бұрын
Can you make a video about memory page algorithme ( eg : working set, LRU, FIFO ... )?
@denisela34036 жыл бұрын
THANK YOU!!!
@toumakoushik314166 жыл бұрын
Need a video about multitasking
@bazoo513 Жыл бұрын
0:45 - The difference between people and processors doing "multitasking" is that the latter do context switch much faster 😀
@mimischly25472 жыл бұрын
Real nice sir thank you
@paullawrence72758 ай бұрын
How is it that a program has multiple processes, each process executing the same program, if the program has to be executed sequentially? And the same question for multi-threading?
@GaryExplains8 ай бұрын
Programs can be written so that they aren't executed sequentially. Think of a web server, it can start a new thread for each request that it receives.
@gandamrx5 жыл бұрын
Will you have any plan of doing Gary Explains on GPU processing and parallelization. Thank you.
@リンゴ酢-b8g2 жыл бұрын
note to self: adding more threads plays heck with the idea of performance gain
@the-real-i93 жыл бұрын
I love this!
@arminharper5104 жыл бұрын
Now it seems like the new version of C++ is going to be all about asynchronous functions and multi tasking/threading/Processing and it makes sense since now even Smartphones and smartwatches are switching to multicore CPUs.
@ADITISHASTRI-i5h13 күн бұрын
thanks
@aravindraj57926 жыл бұрын
Nice video sir. Can you explain hyper-threading? Is it same as multi- threading?
@GaryExplains6 жыл бұрын
Hyper-threading is a hardware technology to try to improve overall performance by making a CPU look like it has more CPU cores than it really does. If you think it is worth while I can add that to my TODO list.
@aravindraj57926 жыл бұрын
Gary Explains Make a video on it if possible. Thanks for the reply.
@gr34736 жыл бұрын
It will be interesting to see if it really works and how much faster is i7 compared to i5 with the same number of cores but more threats.
@gabrielmaguire4 жыл бұрын
Beautiful thank you!
@GaryExplains4 жыл бұрын
Glad you like it!
@abhishekgupta-yh2vn6 жыл бұрын
Hi Gary.Thanks for such a great video. Also,it would be great if you could share the multi-threading code
@GaryExplains6 жыл бұрын
I have already, it is up on my GitHub: github.com/garyexplains/examples
@mohammedk.h.f30162 жыл бұрын
Thank you
@amallkrishna6 жыл бұрын
Gary, I have a question. Why didn't the non threaded program use all 4 of the cores?
@GaryExplains6 жыл бұрын
Well that is the key, single threaded programs can ONLY use one core because computer programs are sequential in nature and can only be run in parallel if they are specifically written that way.
@ironhide99554 жыл бұрын
could you share the program which you used for running? which programming language you have used for writing?
@GaryExplains4 жыл бұрын
The code is in my public GitHub repo: github.com/garyexplains/examples
@basantapoudel46956 жыл бұрын
Nice explation. Could you please also explain how these three terms can be viewed in multiple processor computer scenário ? Thank you.
@uttamchandra97266 жыл бұрын
Hiiii hello !!!!! A very good afternoon professor !!!!!! Sorry for the late wishes !!!!!
@_Digitalguy6 жыл бұрын
One more vote for a multitasking video!!
@hukeskypotter51496 жыл бұрын
✅ I am surprised how I didn’t find your channel till yesterday
@Julian-tf8nj2 жыл бұрын
Your test programs aren't in python, are they? With python, there are complexities from the GIL
@GaryExplains2 жыл бұрын
No, in C. Code is in my GitHub repo.
@arkadianriver6 жыл бұрын
This was a great comparison except I feel sad for the single core multi-thread, because you were showing a CPU-intensive process. Multi-threading can be very beneficial even on a single core if your threads are waiting for other things besides time to share the single core, such as sending out 10 requests to download different files is much better than sending out 1 request at a time, since you're having to wait for the network.
@shashankshekhar89704 жыл бұрын
In case of threading on a 4core machine, shouldn't GIL have restricted the execution to only one thread at a time since these are CPU intensive operations?
@GaryExplains4 жыл бұрын
Are you referring to Python's GIL?
@shashankshekhar89704 жыл бұрын
@@GaryExplains yes, I meant the Python GIL. Since GIL restricts only one CPU based thread to execute at a time how was the program able to make use of all the 4cores? Am i missing something here
@GaryExplains4 жыл бұрын
@@shashankshekhar8970 The test programs that I used aren't written in Python.
@suryaajha59535 жыл бұрын
This was tooooooooooo goood
@xeonrafi3 жыл бұрын
Hi Gary, can you please share the demo code (prime number calculation) of the video? I want to test the same benchmark for pi-4. Thanks.
@GaryExplains3 жыл бұрын
It is in my GitHub repo. Just Google "garyexplains GitHub"
@Eric-jt9nj6 жыл бұрын
Great explanation and evidence shown👍 I'd like to recreate this experiment on other computers. Is it possible to have the code published here?
@GaryExplains6 жыл бұрын
I have uploaded the code to my github repository: github.com/garyexplains/examples