This video was sponsored by Brilliant. To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/CoreDumped. You’ll also get 20% off an annual premium subscription.
Where are you going after you die? What happens next? Have you ever thought about that? Repent today and give your life to Jesus Christ to obtain eternal salvation. Tomorrow may be too late my brethen😢. Hebrews 9:27 says "And as it is appointed unto man once to die, but after that the judgement
i have been started watching your video recently and you know what your videos are great cuz for me they are easy to comprehend. i also had an humble request can you make some videos on computational structure, please!!!
I have always wondered what the actual difference between threads and cores are, and YOU are the first one to explain it in a way that can be perfectly understood. Your animation style is also really great.
Are you sure you are referring to the same thing? I've always wondered about hardware multi threading (as in intel's hyper threading) and initially thought this video is going to explain those, but it seems it's the OS concept of threads (which is also interesting). Or maybe I got it wrong, who knows.
@@f14v14nhyper threading is a marketing term. There are two cores who share some resources like main memory and cache. And hyper threading refers to sharing of seldomly used compute circuits like division, floating point coprocessor , and MMX . No registers are shared.
Thats cause in terms of hardware, threads is also language to say "concurrent threads processing capability". 1 word 2 meanings. So that my CPU has 8c16t means it has 8 physical cores and capability of doing 16 things at once. But in my OS probably there is over 1000 threads.
Another amazing video! I would suggest the following definition: "a thread is an execution context". I think that's a good way to think about threads because they provide everything needed to run the next instruction, like its own program counter, stack, and registers.
This is the best video I've watched on this. This helped me gain a more intuitive understanding of threads vs processes, whereas a lot of other explanations confused me.
People really need to understand that videos like these are better learning tools than books or people explaining it to you with just words and PDF files on board screen.
When deciding should I go with Threads or Process spawn for a project I remember reading that the difference between Threads and Processes is that Threads share the same memory while Processes not.
That's why the famous Philosopher around the table problem is so good. Try implementing the logic of the philosophers around the table sharing forks to take turns eating using both Threads and Processes and you will quickly understand the 'memory space' dillema. Once you finished the implementation try using 200 philosophers in each case and see how your computer reacts :)
Last bit of threads executing the same piece of code clarifies a lot of confusion. Since it’s read-only and is fetched-decoded-executed. Brilliant explanation with careful wording. Love your videos.
bro.... your're broking the internet with these AWSOME AWESOEM CONTENTS !!!!!! 10++++++++++++++++++ i'm speechless for the quality and the effort profused !!!!!!!!!!!!!!
Great video, never seen such precise, succinct and clear explanation on this topic. It shows how your understanding is deep and broad at same time. Thankyou so much.
Your videos are fascinating. You made me interested in the work of operation systems. Schematics are great for explaining stuff like this. Keep the quality
EXCELLENT presentation. You did it basically exactly the way I would like to have it explained. Perfect, down to using different colors for different processes/threads, etc.
Woah man, this is peak content on youtube. Programming in python as a kid left me thinking that threads are free parallel execution (only somewhat correct) and used them for whatever I wanted without knowing what they are actually for (this caused problems). Now thanks to this video, I know how it is actually operated. And just as a sidenote, I actually found out that variables are stored in the thing programmers call the stack from when you brought it up in this video, im not in college yet and am trying to learn computer architecture so this entire video was huge for me, as with all your videos. Insanely great.
Thank you so much for this video, that I have found absolutely accurate, and with excellent graphics. I can confirm that on Solaris (the UNIX flavour that used to run on SUN workstations), threads were based on lightweight processes. I also remember that prior to the Posix standard for threads, portability among different O.S.’s was very challenging. And I would also stress the fact that when it comes to threads, with great power come great responsibilities, especially when handling concurrent access to shared data structures, and more in general, thread synchronization. A whole field of study, in I.T. science, is dedicated to this, and one has to master it perfectly in order to build correct and robust multithreaded S/W.
In one of my computer science classes (several years ago), my teacher told me that a process can be used to share memory resources and a thread to share computing resources. Great video !
Great video ! I would recommend a small correction though. Around 14:30 you said that TEXT and DATA section are two regions that are never written too. This is mostly true, but remember that the data section is where static variables are stored. So if a Thread has to change a static variable it will write into the data section.
Will you be teaching anything about networking? Would really like to know the low levels of how data goes from someone's server to my computer. That is basically magic for me, how thousands of devices share the same fiber optic line and can communicate completely fine.
Only two devices sit on a Fiber (at the ends ). Manufacturing seems to have advanced to make the individual finer thinner . And diodes are packed more dense at the ISP side. Basically an (O)LED display for download and a camera for upload.
I don't think there was really anything in this video that I didn't knew before. But it still helped me to put so many things together in my head and get a much better understanding. Thank you
Graduated from Uni and somehow threads were just glossed over. Though I've used them, I had never really taken the time to learn much about them until today. Thanks!
I'm learning computer from the ground-up. Watched view videos from this channel about logic and processor, thanks for the videos.. Now im learning softwareside and now this video helped to get the concept
amazing and intense video just one detail i would like to point is that c and c++ are mostly considered mid-level languages since they can be written and understood by humans but they give you some of the power of booth high and low level languages. the video really anwered a lot of questions that i had in my mind thankss.
Bro cooks with every video he makes. one of the best channel out there. I'm cheering for u to continue. I believe that in a few years, your channel will become the ultimate compilation of everything there is to now about programming. Best of luck to u ❤
Nice waiting for multi-core video, if we see in future video related to GPU that would be fantastic, how vertex and pixel shaders works and etc, that would be fantastic.
Modern languages makes it "easy" to multithread. In iOS, with Objective-c and earlier Swift versions, we needed to use the "Grand Central Dispatch" API to run code in a multithreaded way. It wasn't hard but sometimes, it could lead to messy code. In the newer swift versions, if we put any code in a "Task { code... }" block, it automatically creates threads in the background so it is very easy to create high performing, async, multihreaded, memory safe applications, everything is managed in the OS.
Before watching, I am gonna guess threading is important at least in part because there would be quite a bit of processor downtime/inefficiency if tasks were not sharing time on a core. That is the first thing that popped into my head, if a core was just in charge of one task then it’d be idling quite a bit waiting for things like memory to be retrieved or user input, etc. I may be misunderstanding the subject though because I don’t know hardware that well Edit: I was not wrong, but only because I was so vague in my prediction. What a clever explanation, now I have a better understanding when I am using threading in my programs, this will help me design better
Awesome video I was also wondering if you are interested in making a video on the asynchonous programming, and how that works under the hood. For a long time I though the async keyword in javascript or python creates a new thread of execution, but I was wrong. Actually it's the event loop that manages the execution of these codes. I would like to explore this in much depth, but if you could make a video comparing this alongside the threads, it would be a huge help. Thanks for making this video and others in your channel, they are really in depth and informative.
I would love to learn more about the mechanisms in hardware related to synchronization. I have coded in C++ and understand how to use a mutex, but understanding how it works in detail and how that relates to the hardware is a different matter
So, considering the browser example: Was I right in understanding that when creating a thread and pointing to a function (essentially the "main" function), the OS understands, "Aha, from here on, the thread starts executing"? This function is a smaller part of the larger executable, right? Does the thread specify from where to where in the text segment it should execute? And if I open two more tabs, does it matter that each created thread starts at the same address in the text segment? Can I simplify this and say that, for the PC, each tab looks like another browser instance was opened, even though it's not a separate process? Instead, it’s the same algorithm being read and initialized for another thread.
Thanks for this excellent video on threads. When you mentioned them, it made me wonder how asynchronous functions work under the hood. Are you going to do a video on asynchronous functions?
At 3:10, whilst you do mention that each process traditionally has 1 program counter, the solution after a long explanation is to simply have multiple program counters, along with sharing of the rest of the resources. I think that could have been better explained because I was waiting for a much different approach to the problem, than a simple, "but to run multiple tasks in a process, OS' use a different approach than the traditional process model", but if it is not a different process model then it's not wholly correct to say that "in traditional process model, one process can only have one program counter" (something along those lines).
I always wondered how the kernel does thread scheduling on a single core without falling back to spin based event loops and other inefficient approaches.
Just one question, you mentioned how if a process encounters an error (like the graphics part of a browser tab) then it can be halted by the OS without taking down other processes of the program being run... Is the same true for threads, can a thread encounter an error without taking the process down with it?
Depends of what kind of error. For example if you try to read a file that doesn't exist, thats an error that most likely won't make your program crash, but something like a segmentation fault will cause the OS to immediately terminate the process, taking down all its threads with it.
we can get an idea of what is a thread in SW but what is threads and cores in a CPU? as they are mentioned in a Processors specification say intel i9 / i7? can you explain that too?
at 0:53 isn't it parellelism as concurrency is the term used to set of independent codeblocks which can possibly processed simultaneously Correct me if I am wrong
@@CoreDumpped Concurrency can take advantage of parallelism in systems that have multiple cores - I agree with this point concurrency is still a thing in single core systems - in this the program contents are saved and the PCB is added back to the queue in algos like RR, is it still considered as concurrency (I am asking as these things involves Context switch)
Thank you so much for such amazing content, what an enlightenment it was… One follow up question, if all threads have different program counters, does that mean multiple Program Counter registers HW are there, or is it logically you were to?
This video was sponsored by Brilliant.
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/CoreDumped. You’ll also get 20% off an annual premium subscription.
Where are you going after you die?
What happens next? Have you ever thought about that?
Repent today and give your life to Jesus Christ to obtain eternal salvation. Tomorrow may be too late my brethen😢.
Hebrews 9:27 says "And as it is appointed unto man once to die, but after that the judgement
i have been started watching your video recently and you know what your videos are great cuz for me they are easy to comprehend. i also had an humble request can you make some videos on computational structure, please!!!
what program did u use to make video?
Brilliant? - lame
Man your videos are diamonds.. I am so blessed that i found you
Welcome aboard!
Same
@@CoreDumpped Where i Can find any course like this
utterly useless info with a robot voice, you're just his alt account i think
@@adamrushford nah, do your research man
This was awesome, eagerly waiting for more videos.
Thank you for explaining it in such detail while making it simple to visualise/understand 🙌
Dude i just went to your channel to see if the new threads video is out, and i see that it has been released 30 seconds ago :D
Perfect sync mate!
I have always wondered what the actual difference between threads and cores are, and YOU are the first one to explain it in a way that can be perfectly understood. Your animation style is also really great.
Are you sure you are referring to the same thing? I've always wondered about hardware multi threading (as in intel's hyper threading) and initially thought this video is going to explain those, but it seems it's the OS concept of threads (which is also interesting).
Or maybe I got it wrong, who knows.
@@f14v14nhyper threading is a marketing term. There are two cores who share some resources like main memory and cache. And hyper threading refers to sharing of seldomly used compute circuits like division, floating point coprocessor , and MMX . No registers are shared.
Thats cause in terms of hardware, threads is also language to say "concurrent threads processing capability". 1 word 2 meanings. So that my CPU has 8c16t means it has 8 physical cores and capability of doing 16 things at once. But in my OS probably there is over 1000 threads.
@@by010 16 threads per core?
I understand, now!
This is by far the best animation and explanation I have seen on RUclips about Process vs Threads
Another amazing video!
I would suggest the following definition: "a thread is an execution context".
I think that's a good way to think about threads because they provide everything needed to run the next instruction, like its own program counter, stack, and registers.
Where i Can find any course like this .
The more you know and understand about how modern hardware and software works, the more unbelieveable it is.
Thanks!
Where i Can find any course like this
BRO Just to late 2 hours ago i have operating system exam and the question is why we need threads on single core porcessors.
Bad timezone
@@tomasprochazka6198 absolutely
@@tomasprochazka6198 absolutely
Amazing video
Lame question. Define "need".
This is the best video I've watched on this. This helped me gain a more intuitive understanding of threads vs processes, whereas a lot of other explanations confused me.
Best channel for PROgrammers
People really need to understand that videos like these are better learning tools than books or people explaining it to you with just words and PDF files on board screen.
make video on allocating memory on heap vs stack,
also about the virtual memory, segmentation and pages and how are they managed using tables and shit
Memory allocation videos are already on his channel
You mean if multiple threads share memory?
When deciding should I go with Threads or Process spawn for a project I remember reading that the difference between Threads and Processes is that Threads share the same memory while Processes not.
That's why the famous Philosopher around the table problem is so good. Try implementing the logic of the philosophers around the table sharing forks to take turns eating using both Threads and Processes and you will quickly understand the 'memory space' dillema.
Once you finished the implementation try using 200 philosophers in each case and see how your computer reacts :)
@@robuandrei5969 yeah that's something I should try implementing, but I got the issue small scale when I was poking into synchronization in Vulkan.
Last bit of threads executing the same piece of code clarifies a lot of confusion. Since it’s read-only and is fetched-decoded-executed.
Brilliant explanation with careful wording. Love your videos.
bro.... your're broking the internet with these AWSOME AWESOEM CONTENTS !!!!!! 10++++++++++++++++++ i'm speechless for the quality and the effort profused !!!!!!!!!!!!!!
Awesome Video as always!
Impressed by your Animations as they make it really easier to understand!
Thank You.
Great video, never seen such precise, succinct and clear explanation on this topic.
It shows how your understanding is deep and broad at same time.
Thankyou so much.
Your videos are fascinating. You made me interested in the work of operation systems. Schematics are great for explaining stuff like this. Keep the quality
Please keep posting videos like these (related to OS and Computer Hardware related stuff). ❤
The best thing is I found your channel. I never would have been learned about thread with such clarity. Thank you so much.❤
EXCELLENT presentation. You did it basically exactly the way I would like to have it explained. Perfect, down to using different colors for different processes/threads, etc.
Woah man, this is peak content on youtube. Programming in python as a kid left me thinking that threads are free parallel execution (only somewhat correct) and used them for whatever I wanted without knowing what they are actually for (this caused problems). Now thanks to this video, I know how it is actually operated. And just as a sidenote, I actually found out that variables are stored in the thing programmers call the stack from when you brought it up in this video, im not in college yet and am trying to learn computer architecture so this entire video was huge for me, as with all your videos. Insanely great.
Sir, you deserve a medal for making Operating Systems and Computer Architecture cool.
These videos are truly excellent and I'm amazed and grateful you still have more planned!
I really really loved this explanation. The visual way you explain it make it much easier to grasp. Thanks a lot for this!!!
Thank you so much for this video, that I have found absolutely accurate, and with excellent graphics.
I can confirm that on Solaris (the UNIX flavour that used to run on SUN workstations), threads were based on lightweight processes.
I also remember that prior to the Posix standard for threads, portability among different O.S.’s was very challenging.
And I would also stress the fact that when it comes to threads, with great power come great responsibilities, especially when handling concurrent access to shared data structures, and more in general, thread synchronization. A whole field of study, in I.T. science, is dedicated to this, and one has to master it perfectly in order to build correct and robust multithreaded S/W.
I studied computer engineering and your videos still get me excited 😊
your video's always the best and easy to understand. I was struggling imagining all these stuffs during my computer science study
Man you're THE BEST! Much much appreciation! Thank you!
In one of my computer science classes (several years ago), my teacher told me that a process can be used to share memory resources and a thread to share computing resources.
Great video !
Great video ! I would recommend a small correction though. Around 14:30 you said that TEXT and DATA section are two regions that are never written too. This is mostly true, but remember that the data section is where static variables are stored. So if a Thread has to change a static variable it will write into the data section.
+1 this. He probably meant CDATA (the constant data), but yes, DATA is 100% modifiable, and needs to be protected for multiple thread access
Will you be teaching anything about networking? Would really like to know the low levels of how data goes from someone's server to my computer.
That is basically magic for me, how thousands of devices share the same fiber optic line and can communicate completely fine.
Only two devices sit on a Fiber (at the ends ). Manufacturing seems to have advanced to make the individual finer thinner . And diodes are packed more dense at the ISP side. Basically an (O)LED display for download and a camera for upload.
In a word, which requires a bit of research: "Multiplexing".
the clearest explanation of threads I've ever heard, thank you!
I don't think there was really anything in this video that I didn't knew before. But it still helped me to put so many things together in my head and get a much better understanding. Thank you
I thought the exact same thing.
I knew it most of the stuff except the text part in the process with how threads access them, now threads are mostly sorted in my mind thanks.
Oh we're getting spoiled now. The extra smooth 60fps is *chef's kiss*. Excellent video as always Jorge!
You are amazing. Can explain these concepts so perfectly
My brain starts to grow again, thanks mate. Love you so much.
Your channel is ameazing!! Congratulations!
Graduated from Uni and somehow threads were just glossed over. Though I've used them, I had never really taken the time to learn much about them until today. Thanks!
Great video, hats off to your efforts.
I'm learning computer from the ground-up. Watched view videos from this channel about logic and processor, thanks for the videos..
Now im learning softwareside and now this video helped to get the concept
It is impossible to overstate how well done this video is. 👏🏻
Perfect explanation of threads vs processes!
amazing and intense video just one detail i would like to point is that c and c++ are mostly considered mid-level languages since they can be written and understood by humans but they give you some of the power of booth high and low level languages.
the video really anwered a lot of questions that i had in my mind thankss.
I was waiting for your next video. Nice Work!
Amazing video, great explanation!!
Great Animation! Thank You!
I love that you show concrete examples it makes it so much easier to understand
bro this video so cool, pls make another for hardware threads.
Perfect timing to watch during lunch
Bro cooks with every video he makes. one of the best channel out there. I'm cheering for u to continue. I believe that in a few years, your channel will become the ultimate compilation of everything there is to now about programming. Best of luck to u ❤
Your videos are absolutely brilliant, many thanks for the great work.
I have a test about this topic and the next video's tomorrow haha, pretty awesome video
Thank you CoreDumped, very cool!
13:18 That's not a problem if you ask me...
Nice waiting for multi-core video, if we see in future video related to GPU that would be fantastic, how vertex and pixel shaders works and etc, that would be fantastic.
Love it ! Make a series on it ❤, can you explain coroutines with your animations .
Very nice video and explanation. When can we expect the next video?
Modern languages makes it "easy" to multithread. In iOS, with Objective-c and earlier Swift versions, we needed to use the "Grand Central Dispatch" API to run code in a multithreaded way. It wasn't hard but sometimes, it could lead to messy code. In the newer swift versions, if we put any code in a "Task { code... }" block, it automatically creates threads in the background so it is very easy to create high performing, async, multihreaded, memory safe applications, everything is managed in the OS.
Nice videos id love to see you explain how peripheral devices drivers etc and the internet works on the hardware level
As a self-taught guy constantly getting belittled, I enjoy learning from your channel as well as lowlevel.
this channel is pure gold
Before watching, I am gonna guess threading is important at least in part because there would be quite a bit of processor downtime/inefficiency if tasks were not sharing time on a core. That is the first thing that popped into my head, if a core was just in charge of one task then it’d be idling quite a bit waiting for things like memory to be retrieved or user input, etc. I may be misunderstanding the subject though because I don’t know hardware that well
Edit: I was not wrong, but only because I was so vague in my prediction. What a clever explanation, now I have a better understanding when I am using threading in my programs, this will help me design better
Bro you deserve 1mil subs the content is so fire
Awesome video
I was also wondering if you are interested in making a video on the asynchonous programming, and how that works under the hood. For a long time I though the async keyword in javascript or python creates a new thread of execution, but I was wrong. Actually it's the event loop that manages the execution of these codes.
I would like to explore this in much depth, but if you could make a video comparing this alongside the threads, it would be a huge help.
Thanks for making this video and others in your channel, they are really in depth and informative.
I will, but you guys need to wait because making these videos is time consuming!
Unbelievable that this amazing channel has only 160,000 subscribers!
I would love to learn more about the mechanisms in hardware related to synchronization. I have coded in C++ and understand how to use a mutex, but understanding how it works in detail and how that relates to the hardware is a different matter
With Virtual threads in Java 23, you can have millions of virtual threads in JVM on a platform thread, that means good resource utilization
Wonderful video. This kind of videos should be shown in CS classes.
This is incredible. Thank you very much!!!!!
These animations are awesome! Which programms/tools are you using for your videos?
It's been stated in previous videos that he is using PowerPoint.
So, considering the browser example: Was I right in understanding that when creating a thread and pointing to a function (essentially the "main" function), the OS understands, "Aha, from here on, the thread starts executing"? This function is a smaller part of the larger executable, right? Does the thread specify from where to where in the text segment it should execute?
And if I open two more tabs, does it matter that each created thread starts at the same address in the text segment? Can I simplify this and say that, for the PC, each tab looks like another browser instance was opened, even though it's not a separate process? Instead, it’s the same algorithm being read and initialized for another thread.
Thanks for this excellent video on threads. When you mentioned them, it made me wonder how asynchronous functions work under the hood. Are you going to do a video on asynchronous functions?
At 3:10, whilst you do mention that each process traditionally has 1 program counter, the solution after a long explanation is to simply have multiple program counters, along with sharing of the rest of the resources. I think that could have been better explained because I was waiting for a much different approach to the problem, than a simple, "but to run multiple tasks in a process, OS' use a different approach than the traditional process model", but if it is not a different process model then it's not wholly correct to say that "in traditional process model, one process can only have one program counter" (something along those lines).
Keep it up.👏
Your videos are amazing.
I can see that a lot of effort has been done on this video that even though thankfully I know this info I am still urged to watch it
Can you cover the topic of cpu cores and how they work?
hey george, which software are you using for your animations? It looks nice
thx
PowerPoint
this information is amazing!
thanks!
I always wondered how the kernel does thread scheduling on a single core without falling back to spin based event loops and other inefficient approaches.
Badly waiting for the NEXT One... with Multiple Core & Parallelism ❤️❤️
Just one question, you mentioned how if a process encounters an error (like the graphics part of a browser tab) then it can be halted by the OS without taking down other processes of the program being run...
Is the same true for threads, can a thread encounter an error without taking the process down with it?
Depends of what kind of error. For example if you try to read a file that doesn't exist, thats an error that most likely won't make your program crash, but something like a segmentation fault will cause the OS to immediately terminate the process, taking down all its threads with it.
we can get an idea of what is a thread in SW but what is threads and cores in a CPU? as they are mentioned in a Processors specification say intel i9 / i7? can you explain that too?
Great video, very well explained
Maaaannn... Your the Lost Diamond... Glad I found you 6 months ago...❤️❤️
This series is great. Is there a plan to cover asynchronous runtimes in the future?
It would be interesting if you could explain, how CPU branching and speculative execution come into play
this is the kind of video you want to watch instead of playing in background
no pun intended
Great video, thanks!
How do lambda functions work? Are they in the .text section too?
Yes
The executable part yes, but their value bindings are on the heap.
U got a sub and new fan🎁, loved the topic ❤️
at 0:53 isn't it parellelism
as concurrency is the term used to set of independent codeblocks which can possibly processed simultaneously
Correct me if I am wrong
It is not. Concurrency can take advantage of parallelism in systems that have multiple cores but concurrency is still a thing in single core systems.
@@CoreDumpped Concurrency can take advantage of parallelism in systems that have multiple cores - I agree with this point
concurrency is still a thing in single core systems - in this the program contents are saved and the PCB is added back to the queue in algos like RR, is it still considered as concurrency (I am asking as these things involves Context switch)
0:38 that's a beautiful animation
Thank you so much for such amazing content, what an enlightenment it was…
One follow up question, if all threads have different program counters, does that mean multiple Program Counter registers HW are there, or is it logically you were to?
Parallelism with multi cores would be really fascinating to watch. Great visual representation.
This ought to be interesting when you start to get into the idea of mutexes, fences, barriers, etc.
Does anybody know if the explained concept of threads also counts for the free rtos on microcontrollers?