FANG Interview Question | Process vs Thread

  Рет қаралды 277,710

ByteByteGo

ByteByteGo

Жыл бұрын

Subscribe to our weekly system design newsletter: bit.ly/3tfAlYD
Checkout our bestselling System Design Interview books:
Volume 1: amzn.to/3Ou7gkd
Volume 2: amzn.to/3HqGozy
Other things we made:
Digital version of System Design Interview books: bit.ly/3mlDSk9
Twitter: bit.ly/3HqEz5G
LinkedIn: bit.ly/39h22JK
Animation tools: Illustrator and After Effects
ABOUT US:
Covering topics and trends in large-scale system design, from the authors of the best-selling System Design Interview series.

Пікірлер: 125
@fieryscorpion
@fieryscorpion Жыл бұрын
This is how video lessons should be done; plenty of diagrams and animations instead of someone just talking. Thanks!
@TannerBarcelos
@TannerBarcelos Жыл бұрын
Building a house is a process, but the people doing the work to install the pipes, paint the walls and do the electrical work are all the working threads within the process of building the house. I like to use threads synonymously with “unit of work” or “thing that executes a specific piece of work / action for the process to complete successfully. So if I run chrome, and have 10 tabs open, I will have 10 processes running. Within each process are 1 or many units of work (called threads) responsible for memory management, access, logic, etc. I believe the house analogy works well in a lot of cases Also, I was asked this question in an interview during a Comp. Sci. Fundamentals round during the systems design portion of my interview process at a large, global company we all interact with daily. (Keeping vague for obvious reason)
@ayubbrow3880
@ayubbrow3880 18 күн бұрын
brov why don't you make a video the house example is very brilliant
@futurexjam2
@futurexjam2 Жыл бұрын
Thread is the mechanism of sending instructions from a program(process) to CPU. Threads are OS based mechanisms, also processes are too but a process includes at least one thread. You can imagine that a process is encapsulation of a thread or threads. The OS looks at the program(when you click an executable), creates an executing process for the execution of the program and in the process the thread or threads are the carrier of instructions which are sent to the CPU. This is the execution mechanism of a program in an OS. When you create a thread rather than the main thread, you say to the OS that in this thread those instructions should run in a different context, that will create a context switch(that is execution of instruction(s) given by a thread to the CPU in a determined duration), and by that, you will see imaginary parallel execution of different instructions in different threads. Maybe one second long instruction set will be executed in a one short lived thread while another long running thread (especially main thread) keeps running and by that short living thread will not wait the long running thread to be finished. That is the magical part of multi threaded executions.
@TheZhouh12
@TheZhouh12 Жыл бұрын
@@mils3318 Yes, it is possible to run multiple threads in parallel within a single process in most modern operating systems. A process can have multiple threads of execution, which are also known as lightweight processes. Each thread runs concurrently and shares the process's resources, including memory and open files.
@mohamedshahrul1750
@mohamedshahrul1750 Жыл бұрын
bro, we hate to read so that's why watching video but bro is writing essay here🤣🤣
@mils3318
@mils3318 Жыл бұрын
​@@TheZhouh12 so it is possible that, for example, if we have a 8-core CPU on it, in one currently active process, multiple threads can be executed in parallel... not multitasking. Okay, thank you very much.
@TheZhouh12
@TheZhouh12 Жыл бұрын
@@mils3318 When a CPU has multiple cores, it can execute multiple threads concurrently, as long as the operating system supports it. This is known as parallel processing.
@TheZhouh12
@TheZhouh12 Жыл бұрын
@@mils3318 On a system with a single-core CPU, the operating system can still create multiple threads and schedule them to be executed one after the other, but they will not be able to run concurrently. This is known as multitasking.
@furitoraUfc
@furitoraUfc 3 ай бұрын
I have to admit... I have never seen such good explaination videos merged with animations and diagrams in my life. GREAT CONTENT SIR! Keep on doing what you do.
@rickywj
@rickywj Жыл бұрын
Fantastic video - concise and clear explanations accompanied by extremely helpful visuals. Couldn't ask for a better description within 4 minutes of time. Subscribed!
@orterves
@orterves Жыл бұрын
All information that I knew but would be hard-pressed to scoop out of my brain on demand - it's great to have clear and succinct refreshers like this to keep the neurons fresh
@milad8436
@milad8436 Жыл бұрын
Great channel. Simple, short and straight-forward
@jennwng
@jennwng Жыл бұрын
I really love these videos!!! The visuals are very helpful to build mental models and understand these complex concepts - thank you so much!!!
@johnvandenberg1448
@johnvandenberg1448 Жыл бұрын
Recently came across your channel. Love the content. Very informative yet short enough to digest unlike most other tech videos
@muzammilnxs
@muzammilnxs 11 ай бұрын
Analogy for understanding process and thread • In essence a program/process/thread is executing a job(a set of instructions). So, in that context, it’s no different than physical labour work where one executes a bunch of instructions from his/her brain and uses the required tools to complete a job • Imagine you hire a fitter to mount your newly bought TV and you have already bought a TV mount. Here, the fitter represents a program. He has skills required to mount the TV(Set of instructions) and required tools(Data, library, plugins) • Hiring a fitter is equivalent to installing a program. You have got commitment from him/her to work on your job. And he brings himself and loads the tools in your space ready to do the job. But, You have yet to extract the job from him. For this, you need to prepare some physical space near your TV and also give him the authorization to work at your home. This is the equivalent of creating a process where you allocate CPU and ram memory for the program to execute its job • Just as a program can spin up multiple process, a fitter can bring multiple fitters to execute the same job. All of them work independently in their own physical space and with required authorization • So, what's the analogy for threads? A fitter usually breaks the job into sub tasks. Here, mounting a TV can be broken in tasks like punching holes in the wall, preparing the Mount frame, adjusting the tilt etc. These subtasks represent individual threads. These threads are executed in the same memory/heap space just as the fitter performs his subtasks on his original physical space. •Threads can be executed in parallel saving time. You can imagine this to be fitter performing tasks at the same time using his two hands. For example, one hand used to punch holes in the wall and other hand used to prepare the mount frame. This might sound like a stretch but there are some crazy people who could multitask with both hands
@stylecine
@stylecine Жыл бұрын
Holy cow... so clear. So coherent. So neat. The graphics go perfectly with your explanation. Thank you for this.
@PH4RX
@PH4RX Жыл бұрын
1:00 "one process cannot corrupt the memory space of another process" - well, should not be able to.
@Nerdimo
@Nerdimo 8 ай бұрын
I keep getting confused between the two (threads and processes) but this depiction has helped me a ton. Thank you!
@Vinod_Kumar827
@Vinod_Kumar827 Жыл бұрын
Good refresher for me. Thanks once again for the awesome and meaningful video.
@MM-ts9jy
@MM-ts9jy 6 ай бұрын
Thanks for those visuals, I can tell a lot of love went into them
@jennwng
@jennwng Жыл бұрын
Also, would love to see videos on "heap" and "serialization / encoding" (some visuals on why in-memory representation is different from byte sequence would be super super helpful ). Thanks again for these great videos!!!!
@gallewick
@gallewick Жыл бұрын
The graphics and animations are so good! (And the content of course 😄) Thanks for sharing!
@NBopus
@NBopus Жыл бұрын
YOu have a great way of explaining things. Keep the good work! Can't wait you get into subjects like Docker and Kubernetes.
@justmasdd
@justmasdd Жыл бұрын
Thank you! Very clear and useful video content!
@MikeTon
@MikeTon Жыл бұрын
Nice and insightful capture of concepts that I were fuzzy on : thanks for putting this together
@hugohultqvist6132
@hugohultqvist6132 5 ай бұрын
Learnt more in 4 min than from 4 hrs of classes, thank you!
@spattanaik75
@spattanaik75 11 ай бұрын
powerful concepts within just 4 minutes. Thanks
@user-sh5bt6ze6n
@user-sh5bt6ze6n Ай бұрын
The best explanation I watched!
@StephenBeale
@StephenBeale 3 ай бұрын
The standard here is exceptional. Thank you so much for this - I wish my lecturers had taken a leaf out of your book!
@mnmLCoder
@mnmLCoder 4 ай бұрын
love it, short and on point. Also i like your style! directly subbed :)
@michaelhernandez2075
@michaelhernandez2075 10 ай бұрын
Best video on this subject by far
@rickythebird9584
@rickythebird9584 Жыл бұрын
Many many thanks! This is a great video instruction!
@wargreymon2024
@wargreymon2024 18 күн бұрын
gosh, this is so clear and informative
@wwhill8033
@wwhill8033 Жыл бұрын
Excellent Stuff!
@sogolyazdanmadad9483
@sogolyazdanmadad9483 9 ай бұрын
Thanks for the great video!🎉
@ravikumarsuvvari2177
@ravikumarsuvvari2177 Жыл бұрын
Multi tasking and multi threading needs to be well known and especially where to use under what circumstances 🙏
@devictoribero
@devictoribero Жыл бұрын
As always, incredible video! Real great work. I'm so impressed by the animations. How do you create them?
@wahyukoco4562
@wahyukoco4562 8 ай бұрын
great explanation!
@user-qg5ch9xu2o
@user-qg5ch9xu2o 6 ай бұрын
thank you for the information, sr. Subscribed!!!!
@barisballi70
@barisballi70 10 ай бұрын
This video helped me, thank you 😊
@caseyspaulding
@caseyspaulding Жыл бұрын
very good. makes more sense now.
@TheCause41
@TheCause41 4 ай бұрын
Well explained. Thank you.
@nouchance
@nouchance Жыл бұрын
Amazing SIR!
@tyeinstem
@tyeinstem 11 ай бұрын
This is a brilliant video.
@rammehar5531
@rammehar5531 Жыл бұрын
Love you Sir, please keep it up. and Thank you very much
@akshat_tamrakar
@akshat_tamrakar 3 ай бұрын
We need more of these videos
@hoangchu4036
@hoangchu4036 Жыл бұрын
Best explanation!!!
@sungjuyea4627
@sungjuyea4627 Жыл бұрын
Thank you for this video! I got this question in an interview this week, and I wish I could have watched this video before the interview! So concise but detailed explanation! And now I get to know what is the purpose of "yield" in Python. None of the resources about it explain in context of OS and context switching...!
@sergeikharchikov1157
@sergeikharchikov1157 Жыл бұрын
Brilliant channel
@multivalfran
@multivalfran Жыл бұрын
Great video. Thxs
@nasamind
@nasamind Жыл бұрын
simply awesome
@arch_285
@arch_285 2 күн бұрын
Great Video
@pranaypallavtripathi2460
@pranaypallavtripathi2460 Жыл бұрын
Please make more such videos on common interview questions explained so greatly
@aniketbisht763
@aniketbisht763 Жыл бұрын
Hi, can the upcoming videos be on -> http polling (short and long), streaming, websockets etc. ? Thanks your teaching style is just awesome
@Spider-Man_67
@Spider-Man_67 Жыл бұрын
Man you're dope, thanks a lot
@syedahmad5655
@syedahmad5655 3 ай бұрын
clear concise explanation together with great graphics. Would love to know how you guys do your graphics.... Thank you...
@ramazanustun6755
@ramazanustun6755 9 ай бұрын
This 4-minute video explains what my professor could not do in an entire semester.
@tanyacharanpahadi158
@tanyacharanpahadi158 Жыл бұрын
This 4 minute video sums up your years of coding experience.
@chetan_bommu
@chetan_bommu Жыл бұрын
Sir Alex, Please do in-depth videos. The content you post is so amazing but they are covered on a high level. Please go deep and explain things.
@allezvenga7617
@allezvenga7617 Жыл бұрын
Thanks for your sharing
@timovful
@timovful 22 күн бұрын
Well done
@DK-ox7ze
@DK-ox7ze Жыл бұрын
Great video. But I didn't understand how auto yielding reduces the cost of context switching? Because after yielding, context switching will have to be done anyway for the CPU to execute other processes.
@akdisrael
@akdisrael 5 ай бұрын
deserve a subscribe
@cool_guy_Vaibhav
@cool_guy_Vaibhav Жыл бұрын
animation is amazing
@tens0r884
@tens0r884 6 ай бұрын
These animations are beautiful holy. Do you mind sharing just how they were accomplished?
@amber4131
@amber4131 Жыл бұрын
If adding coroutine comparison, that would be perfect!
@vikassangwan9523
@vikassangwan9523 10 ай бұрын
Code in a program, loaded into memory and executed by the processor, it becomes a process❤
@arun2438
@arun2438 Жыл бұрын
You can add subtitles also for a larger audience
@snapman218
@snapman218 Жыл бұрын
This is high quality content, but I'm also curious if you could do a video on how you make your videos? :)
@pierregeopardi1481
@pierregeopardi1481 Ай бұрын
Nice video! What about doing one about coroutines.
@joshuabrard1061
@joshuabrard1061 3 ай бұрын
Good video
@haneulkim4902
@haneulkim4902 Жыл бұрын
Thanks for great video. Two questions, 1. So to run K programs embarassingly parallel via multi-processing you have to have K CPU? If number of CPU < K then it would have to switch context, correct? 2. when we are talking about multi-processing python basically two of same script is copied to each process memory?
@joedroider7879
@joedroider7879 Жыл бұрын
Love your channel. Subscribed to it. If you don't mind, what tool do you use to author the content? I find this to be more engaging vs powerpoint based sessions. Thanks
@thieltube390
@thieltube390 Жыл бұрын
I'd be interested in hearing this too
@patchfox
@patchfox Жыл бұрын
@@thieltube390 Looks like Adobe After Effect
@dharmikshah2251
@dharmikshah2251 8 ай бұрын
For the process having multiple threads, OS would provide time quantum of execution per thread under a process? or each thread would get (1 quantum time / no. of threads in process) time for execution?
@araara967
@araara967 Жыл бұрын
pls upload more videos on operating systems concepts
@ReflectionOcean
@ReflectionOcean Жыл бұрын
A process is a program executing by a processor. A process doesn't share memory with another process. It has a collection of threads: the main thread and the other threads if any. A thread is an execution unit inside a process. It shares the same heap memory with the other threads in the same process. But it has its own stack memory.
@evgenii.panaite
@evgenii.panaite 4 ай бұрын
Captain 😅 it was precisely explained in the video
@Spider-Man_67
@Spider-Man_67 Жыл бұрын
Can you please explain about fibres & co-routines?
@neuroillusion
@neuroillusion Жыл бұрын
It would be much more interesting to watch a video "fibers vs coroutines" :)
@user-oy4kf5wr8l
@user-oy4kf5wr8l 5 күн бұрын
我的娘这么复杂🥲 amazing content tho! Thank you!
@algu1984
@algu1984 Жыл бұрын
The simplest explanation I would say that the Process is virtualization of memory and Thread is virtualization of CPU the rest is following cons
@hotlineoperator
@hotlineoperator Жыл бұрын
What app did you use to create that animated presentation graphics?
@mils3318
@mils3318 Жыл бұрын
And what if we have processors with more cores. Does this mean that we can run more processes at the same time? In that case, do we potentially have higher performance because more processors mean less context switching between processes? Can we run two threads in parallel in one process? Or is only multitasking threads allowed per process (execution one by one)?
@MortyrSC2
@MortyrSC2 Жыл бұрын
_And what if we have processors with more cores. Does this mean that we can run more processes at the same time?_ Yes, every logical core can run one thread. _In that case, do we potentially have higher performance because more processors mean less context switching between processes?_ Hypothetically, if the number of active threads were lower than the number of available logical cores, no context switching would occur. However in reality, even freshly installed system like Windows 10 will have ~100-150 processes running by default, which means context switching is necessary. Higher performance comes from being able to process multiple threads concurrently, not from reduced cost of context switching. _Can we run two threads in parallel in one process?_ Yes, if code was properly written to allow multithreading.
@allentsai1982
@allentsai1982 Жыл бұрын
超讚得
@sB3rg
@sB3rg Жыл бұрын
Do you feel like this same verbage is consistent when considering Erlang?
@morenoh149
@morenoh149 Жыл бұрын
Describe fibers in react
@athatien2553
@athatien2553 Жыл бұрын
I am about to have an interview and this topic has given me a headache for days :(
@chrismenui7344
@chrismenui7344 7 ай бұрын
program - executable instructions of code Program disc + ram + cpu = process process control block(PCB) thread - unit of execution within process stack pointers counters thread vs process? threads (of the same process) run in a shared memory space, processes run in separate memory spaces shared memory virtual memory pages switching ⚠ fibers coroutines
@deghta
@deghta 8 ай бұрын
What program is used for visualization?
@sampathmethuku7428
@sampathmethuku7428 Жыл бұрын
what is the software used for animation
@saadmansakib6612
@saadmansakib6612 10 ай бұрын
I like how he’s a fan of witcher 3
@MrAtomUniverse
@MrAtomUniverse Жыл бұрын
What software was this video made with?
@kovolexiy
@kovolexiy Жыл бұрын
I'm also interested in this question. Did you find it out?
@MrAtomUniverse
@MrAtomUniverse Жыл бұрын
@@kovolexiy nope a lot of channel not willing to share knowledge they scared of competition. What’s your telegram handler let’s research this up
@patchfox
@patchfox Жыл бұрын
@@kovolexiy Looks like Adobe After Effect
@aroon8325
@aroon8325 Жыл бұрын
Does anyone know what animation software is used to create this video?
@dgeo27
@dgeo27 Жыл бұрын
I was thinking of this for a long time. I'd also like to know. Not interested in the animation part. But the diagrams are beautiful
@patchfox
@patchfox Жыл бұрын
@@dgeo27 Looks like Adobe After Effect
@mohokhachai
@mohokhachai 9 ай бұрын
Teaching them plz
@evgenii.panaite
@evgenii.panaite 4 ай бұрын
Read the Windows internals book by Mark Russinovich and you guys will discover the new universe
@tilli7500
@tilli7500 Жыл бұрын
can you or anybody from the comments provide a systematic overview of the relationship(technical,,,,not abstract concepts ///take x86, unix for example)bw mode bits(when exactly they are changed,,,,kindly try to be precise),kernel user mode(relating kernel stack ,,,ig both implementations ie per process,,,one for all)and virtual address spaces?
@flyers2000
@flyers2000 5 күн бұрын
someone explain this to university level at the electron levels. like use logic gates, an electricity because in the end it is just 1's and 0's 1 instruction at a time
@mohokhachai
@mohokhachai 9 ай бұрын
So how many process can 4 ram handle
@brucewayne2480
@brucewayne2480 Жыл бұрын
Lets say for example Chrome uses 2 processes : P1 and P2 each process has 2 threads t1.1, t1.2, t2.1 and t2.2 Firefox has 2 processes: P3 and P4 Each process has 4 threads t3.1, t3.2, t3.3, t3.4, t4.1, t4.2, t4.3, t4.4 How the system will run them knowing that I have an 8 core cpu ?
@KrishnaKumar-yn9wf
@KrishnaKumar-yn9wf Жыл бұрын
They're not all executed at the same time. If you have more than 8 threads, the cores will interleave the execution between the threads and only one thread can make progress at a time using a core.
@brucewayne2480
@brucewayne2480 Жыл бұрын
@@KrishnaKumar-yn9wf thanks but how.the system will prioritze them ? Will it run 8 from firefox ? (Suppose that there is no user interaction) What about the virtual threads ans physical threads ?
@futurexjam2
@futurexjam2 Жыл бұрын
@@brucewayne2480 do you know how does kubernetes manage the distribution of applications into the nodes ? There should be a gauger mechanism which may look at the resource consumption by the processes and other stuff by the OS. Such as kubernetes knows the whole nodes capacity and distributes new coming app installations into them. But I really do not know every detail.
@padawanfan4701
@padawanfan4701 Жыл бұрын
The animation is too fast and too vibrant to catch details. With the monologue and constant changing animation, feels hard to catch up, harder to understand.
@AssadKhan1
@AssadKhan1 Жыл бұрын
This should not be a fang interview question 💁
@yaseengousesamudri9390
@yaseengousesamudri9390 9 ай бұрын
I think your animator is overdoing it, am having trouble focusing on the content. Also, could you pause and take breaks, because it feels like you're rushing. Thank you for the content though.
@nile7999
@nile7999 2 ай бұрын
you want him to pause, instead of you pausing the video? 😂😂😂
@botsynth
@botsynth 3 ай бұрын
Why is Heap inside Process? 0:58
@adama7752
@adama7752 Ай бұрын
The process owns the stack/heap. In that drawing, there is code, data (bss/data/rodata), stack (main thread) and heap (memory to randomly allocate from)
@botsynth
@botsynth Ай бұрын
​​@@adama7752I thought that all threads use the same heap. They store references (or pointers) in their corresponding stacks, but all of them reference to one Heap. Am I wrong? We even need to synchronize threads if different threads access to the same data in Heap.
SSL, TLS, HTTPS Explained
5:54
ByteByteGo
Рет қаралды 676 М.
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 2,4 МЛН
🍟Best French Fries Homemade #cooking #shorts
00:42
BANKII
Рет қаралды 54 МЛН
WHY THROW CHIPS IN THE TRASH?🤪
00:18
JULI_PROETO
Рет қаралды 7 МЛН
Multithreading Code - Computerphile
15:54
Computerphile
Рет қаралды 378 М.
System Design: Why is Kafka fast?
5:02
ByteByteGo
Рет қаралды 1 МЛН
How Do CPUs Use Multiple Cores?
6:00
Techquickie
Рет қаралды 2 МЛН
threading vs multiprocessing in python
22:31
Dave's Space
Рет қаралды 558 М.
Stack vs Heap Memory - Simple Explanation
5:28
Alex Hyett
Рет қаралды 191 М.
Top 7 Ways to 10x Your API Performance
6:05
ByteByteGo
Рет қаралды 307 М.
20 System Design Concepts Explained in 10 Minutes
11:41
NeetCode
Рет қаралды 873 М.
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 986 М.
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 2,4 МЛН