Why Are Threads Needed On Single Core Processors
ฝัง
- เผยแพร่เมื่อ 5 ก.พ. 2025
- This video was sponsored by Brilliant.
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/.... You’ll also get 20% off an annual premium subscription.
In this video we explore the fundamentals of threads.
Questions and business contact:
contact.coredumped@gmail.com
Sponsor my work on Github:
github.com/jdv...
Join our discord server:
/ discord
Follow me on twitter:
twittter.com/c...
Twitch:
/ coredumpped
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
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 was awesome, eagerly waiting for more videos.
Thank you for explaining it in such detail while making it simple to visualise/understand 🙌
The more you know and understand about how modern hardware and software works, the more unbelieveable it is.
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!
This is by far the best animation and explanation I have seen on TH-cam about Process vs Threads
Animation is amazing agreed!
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 .
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".
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.
Besides the technical clarity of this video being outstanding, the audio quality of the narration is literally perfect. Would be interesting to see how this was produced.
It’s text to speach (most likely ai enhanced) , not saying that this is sth bad though
right, sounds very much like ai but it’s pretty good in my opinion
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?
Thank you for another great video! No one asked, but here’s another example of data parallelism and why it can be useful.
You can parallelize the following operations on a sequence:
• map
• filter
• reduce
Additionally, you can use parallel sorting algorithms, but not every sorting algorithm is suitable. Only those that align with the “divide and conquer” strategy can be effectively parallelized.
For example, merge sort consists of two main operations:
1. Sort: This has a time complexity of O(n * log n)
2. Merge: This has a time complexity of O(n)
You can perform the sorting phase in parallel processes and then merge the results in the main process, as merging is relatively efficient with its linear complexity O(n)
Cheers!
My god the amount of information packed in 16 minutes is insane. Thank you for the work you do!
God damn... my lecture couldn't clear this concept in a whole semester, which you did in a single video.
and now because of the animations, I would never forget it.
God bless you man.
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.
I wish it was published when I was studying threads 😊
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 !
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.
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.
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
The best thing is I found your channel. I never would have been learned about thread with such clarity. Thank you so much.❤
that's the most beautiful explanation i've ever seen or heard: with its beauty in explaining complex notions in a simple yet vivid way - colourful, using extensive graphics and succinct; and, what's more, DETAILED(!), meaning FINE-GRAINED
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.
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
I really really loved this explanation. The visual way you explain it make it much easier to grasp. Thanks a lot for this!!!
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.
These videos are truly excellent and I'm amazed and grateful you still have more planned!
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.
your video's always the best and easy to understand. I was struggling imagining all these stuffs during my computer science study
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!
I love that you show concrete examples it makes it so much easier to understand
Right! Examples are awesome and make it less abstract
Perfect explanation of threads vs processes!
Awesome Video as always!
Impressed by your Animations as they make it really easier to understand!
Thank You.
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
Static variables don't change
@@saleh8568 You are thinking of constant variables. Static variables are mutable.
Perfect timing to watch during lunch
God bless this guy!!! Thank you very much for creating such resourceful and easy to understand videos. I have binged all the videos in your channel in past few days!
kind of reminds me of Erlang processes, which seems to be a more specific implementation for handling lightweight and fast message passing (such as handling real time), while OS threads are more suited for more general purpose applications that have concurrency needs
Really don't know the specifics of it, but when running an OTP application, every OS thread is used to run the Erlang VM (BEAM), and just like an OS, every process is isolated until specified. Crashes and runtime errors are self-contained in the Erlang process and special processes can be used to automatically restart processes when they crash (called supervisors)
Good Job on explaining, looking forward for more.
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.
It is impossible to overstate how well done this video is. 👏🏻
Please keep posting videos like these (related to OS and Computer Hardware related stuff). ❤
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!
Oh we're getting spoiled now. The extra smooth 60fps is *chef's kiss*. Excellent video as always Jorge!
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 ❤
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.
Love it ! Make a series on it ❤, can you explain coroutines with your animations .
Great video, hats off to your efforts.
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
Just loved it .
Please make more video tutorials. And I am ready to watch a 10-12 hours course on this topics with actual coding demonstration
this information is amazing!
thanks!
bro this video so cool, pls make another for hardware threads.
The prime of this channel never ends. Saludos de uruguay
I have a test about this topic and the next video's tomorrow haha, pretty awesome video
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?
It's worth to know that in programming languages there's a concept of thread pools as an optimization method to avoid new thread spawning each time. And in Java there is a concept of virtual threads which are some kind of a wrapper on OS threads giving more efficiency
@CoreDumped Amazing video one of the best explanations of threads I have seen so far! It would be great if you can also cover the actor model as well
What a video. ++Respect. I just found such a valuable channel both from a programmer's perspective as well as a hardware enthusiast. Please keep making such videos.
This series is great. Is there a plan to cover asynchronous runtimes in the future?
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.
It would be interesting if you could explain, how CPU branching and speculative execution come into play
Very nice video and explanation. When can we expect the next video?
Nice videos id love to see you explain how peripheral devices drivers etc and the internet works on the hardware level
You are amazing. Can explain these concepts so perfectly
Amazing explanation and video. Glad I came across this. Can you please also explain the difference between a cpu core and its virtual core and why it's needed. ?? I mean, when we say stuff like "This Intel chip has 4 physical cores and 8 virtual cores, i.e, two virtual cores for one physical core". What does this mean ?? How does this work ?? And how does it relate to the threads in this video ?? I'll be very grateful if you explain this.
This ought to be interesting when you start to get into the idea of mutexes, fences, barriers, etc.
My brain starts to grow again, thanks mate. Love you so much.
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
this is the kind of video you want to watch instead of playing in background
no pun intended
Could do another video on mutable shared state concurrency with threads, but Halloween was a month ago 😱.
Great vid though 25 years working in the industry as a software engineer, and I still learn new details from these videos.
Excelente la calidad de los videos. Por curiosidad, que herramienta de text to speech usaste? Saludos, y espero que sigan los videos de esta calidad. Gracias.
Hi, I love the way to simulate your topic. May I know which tool you have used to make your video/ presentation? Thx
Can you cover the topic of cpu cores and how they work?
Your channel is ameazing!! Congratulations!
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.
Amazing video, great explanation!!
Man you're THE BEST! Much much appreciation! Thank you!
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?
Great Animation! Thank You!
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
Sir, you deserve a medal for making Operating Systems and Computer Architecture cool.
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 was waiting for your next video. Nice Work!
Great video. How do we know these concepts can be applied to which OSes? Will there be OSes handling processes another way?
Your videos are absolutely brilliant, many thanks for the great work.
One of the best channels I have come across so far..
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.
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.
With Virtual threads in Java 23, you can have millions of virtual threads in JVM on a platform thread, that means good resource utilization
this channel is pure gold
Parallelism with multi cores would be really fascinating to watch. Great visual representation.
hey george, which software are you using for your animations? It looks nice
thx
PowerPoint
U got a sub and new fan🎁, loved the topic ❤️
Simply amazing videos. Would you cover networking in future videos?
awesome content.
btw, I can't tell if it's your narration or AI
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.