Here is what I understood: There are two types of Threads: -User Threads which managed in user space without kernel support -Kernel Threads where managed directly in kernel And these two threads function together there must exist a relationship between them. And the relationship is called Multithreading. There are three ways to establish this relationship, each one having their own advantages and disadvantages. Many to one model: Many user threads to one kernel thread. Threads management happens in user level so it's efficient. However, if one of those user thread makes blocking system call then the kernel thread would be blocked which is connected to other user threads. In other words all other user threads would be blocked, ultimately the entire process would be blocked (considering all those threads associated with same process). In addition, only one thread can access to kernel at a time, it cannot utilize multi-processors fully. Because one kernel thread can run only one of those processors. One to one model: For one user thread there exists one kernel thread. This model basically overcome disadvantages of many to one model such as multiprocessing thanks to multiple kernel threads (for each user thread) and avoiding risk of blocking entire process when one of the thread calls system blocking. Even so it has its own disadvantages including having obliged to create a kernel thread for each user thread which can be costly. Also having too many kernel threads can affect the performance of the application because one kernel thread can run on only one processor. So if you're having multiprocessor system, let's say 4 cores, then creating more than 4 kernel thread causes overhead and burden to the application. Because of this usually applications set limits on how many threads can be created. Many to many model: Many user threads multiplexes to equal or less kernel threads. Definition of multiplex: system or signal involving simultaneous transmission of several messages along a single channel of communication. The number of kernel may be specified depending on the machine or the application. Developer can create user level threads as many as they want. Even after user thread calls blocking system, the entire process won't blocked. Basically it's the most ideal model among all three. Hyperthreading or Simultaneous Multithreading: It's basically whether your system has logical processors. Logical processor is the doubled version of your physical processor (cores). If I have 4 physical processor then I might have 8 logical processor, so my machine can process 8 threads concurrently. To see whether your system supports logical processors (windows) go to cmd and type wmic then type CPU Get NumberOfCores, NumberOfLogicalProcessors. If two numbers are the same then your system doesn't support hyperthreading.
In some systems (especially real-time systems), an asynchronous connection exists between user and kernel threads. That is, a user thread can make a request to a kernel thread, and that request is queued to the kernel thread. The user thread can then continue processing while the kernel thread does its processing (in parallel on a multi-core system). When the kernel finishes, it sends the results to the user thread (either with a callback function of queuing the results to the user thread). This type of user/kernel connection allows a one-to-many relationship. The user thread can be connected to many kernel threads. This relationship also can change the many-to-many relationship. A user thread can connect to many kernel cores, while a kernel thread can connect to many user threads. This is the most powerful of models but also the most difficult to implement. With this many-to-many model, a user thread does not block when a kernel thread does. Each user thread can do more work, increasing the amount of processing a multicore system can do. In addition, each kernel thread can be specialized, making each kernel thread simpler and smaller. Programming to take advantage of these capabilities is more difficult than in the other models. Let me give an example - crypto-mining. The engineer creates many user threads to perform the crypto-mining calculations. One kernel thread delivers the next piece to user threads while another kernel thread receives and records the results. The user thread requests the next piece and waits until it shows up. When it gets that piece, it requests the next (or even several pieces) and then starts processing the piece it has. When it completes, it sends the results to the record thread, gets the next piece off of its queue, and starts processing again. In this example, user threads will process data almost 100% of the time. Kernel threads do not stall user threads, and user threads do not stall kernel threads. However, user and kernel threads must implement these inter-process queues (a non-trivial exercise).
In Linux world, the word "kernel thread" is used to refer to threads running in kernel space, like ksoftirqd, kworker, kswapd etc. which can be shown when you type "ps aux" in the terminal. In this video, "kernel thread" is used as threads managed as "struct task_struct" in the linux source code. User threads on the other hand are like pseudo-threads implemented in userspace, where each user threads are assigned memory area for its stack and CPU resisters saved on pseudo-context-switch, triggered by userspace libraries like tokio (popular asynchronous runtime in Rust). Hyperthreading is a totally different concept, where the CPU shows the OS an illusion that it has more threads than its cores (of course OS can be informed whether hyperthreading is activated or not).
The video is amazing, yet...there is still the open question, how the HyperThreading really works, and is it really a performance-increase along with the the question: how do the L1 and L2 -caches get utilized by the logical-threads then?
Thankyou for the video But there is a correction: Although many-to-many model posses no disadvantages of the other models, in practice it is difficult to implement. Also because modern systems has increasing number of cores (and features like hyper-threading), the kernel thread limitation can be removed. Because of these reasons, most OSs are using the *One-to-One* model instead.
1) Multi-threading - 2 types of threads: user thread and kernel thread - User thread run on top of the OS and is not support by the OS - Kernel thread is support by the OS - A relationship must exist between these 2 threads, called multithreading - 3 types of relationships: many to one, one to one and many to many - Many to one: multiple user threads are linked to only one kernel thread. When an user thread make a blocking system call, it will block the other threads or the whole process. - One to one: one user thread is linked to one kernel thread. This model can solve the many to one problem, but the number of kernel threads is limited, so it limits the user threads created. - Many to many: multiple user thread are linked to an equal or less than number of kernel threads. So when an user thread makes a blocking system call, the other user threads will be scheduled to another kernel thread 2) Hyperthreading or Simultaneous Multithreading (SMT) - Hyperthreaded systems allows their processor core to become multiple logically processors
I will get subscription of your neso app but there are nothing facility to discuss with faculty so please help me sir i have one question can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on single processor system Plzz sir explain me in detail
Hi Nesoacademy... When your channel was hacked and we shifted to a new channel then i too put many tweets to bring back your channel..We were lucky that we got back on that time... I want to say that if you will be providing notes then it will be good for us to keep track...and revise things easily... it's a huge request to provide these notes of the videos. thank you
Hello Abhishek, thank you for your support when we needed it. Our team is working on the notes and soon they will be available on our website + app. You can also use the ppts to revise the lectures, please follow the link www.nesoacademy.org/cs/03-operating-system/ppts
Bro this is not fair because I was searching for videos like this for my exam but not found , but u uploaded it today but I have completed my exam just 1 day back from the date u have uploaded . So sad 😞😞😞😞
@@mwatelaswalehe1506 Thread is created by a process,each time will you open a application it creates a thread for that specific application Which handles the task related to that particular application.
If you want to check if your Windows machine has hyper-threading capability, you can search for system information in the search bar. In the system summary, you can see how many cores and also how many logical processors your machine has
By Kernel threads do you mean hardware threads? So in an one to one user thread to kernel thread mapping it basically means in a system like that no software multithreading would be possible unless it has multiple cores/hyperthreading is enabled?
So, according to my understanding 1 processor, 2 cores (single processor) = can run 2 thread 2 processor, each one core (multiprocessor) = can run 2 thread is my understanding correct? Pls answer this
sir i have learned that each processor has one core and a core have 1 or 2 threads depending whether it is a hyper threading or not BUT for a process they have many segment of threads to get executed.please clarify my doubt.
i can see (2 cores and 4 logical processes it means 4 threads BESIDE that i can see 200 process and 2k threads)in task manager. please clarify my doubt .
@@gopikrishna1551 I think even though there are 2k threads showing in Your task Manager ...there can be maximum of 4 active threads running since You have 4 logical cores and remaining threads are inactive . This is what I think . Correct Me If Iam Wrong .
hey,,i have some kinda complaint about this operatiig system playlist in all other chapters videos are not soo lengthy as this chapter, ths operating system chapter makes mad
You have to click on: ALT+CTRL+DEL then, it shows an some options,then go with task manager and maximize the screen which is newly opened and click on PERFORMANCE button which in top bar then u will see CPU curve below the CPU curve u will finally find that CORES: --- LOGICAL PROCESSORS: --- -Thank you
Why are user threads and kernel threads relationship needed? Cpu only executes kernel threads. So mapping Between user threads and Kernel threads needs to execute user threads.
The mapping between user threads and kernel threads is necessary because the CPU only executes kernel threads directly. User threads, which operate in user space, need to be mapped to kernel threads to: Enable the execution of user-space code. Provide multitasking, concurrency, and parallelism. Allow efficient context switching and management of blocking system calls.
I will get subscription of your neso app but there are nothing facility to discuss with faculty so please help me sir i have one question can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on single processor system Plzz sir explain me in detail
I searched many websites and videos to learn Threading and thank GOD I found the best one in your channel. Thanks a lot for your efforts.
Here is what I understood:
There are two types of Threads:
-User Threads which managed in user space without kernel support
-Kernel Threads where managed directly in kernel
And these two threads function together there must exist a relationship between them. And the relationship is called Multithreading. There are three ways to establish this relationship, each one having their own advantages and disadvantages.
Many to one model: Many user threads to one kernel thread. Threads management happens in user level so it's efficient. However, if one of those user thread makes blocking system call then the kernel thread would be blocked which is connected to other user threads. In other words all other user threads would be blocked, ultimately the entire process would be blocked (considering all those threads associated with same process). In addition, only one thread can access to kernel at a time, it cannot utilize multi-processors fully. Because one kernel thread can run only one of those processors.
One to one model: For one user thread there exists one kernel thread. This model basically overcome disadvantages of many to one model such as multiprocessing thanks to multiple kernel threads (for each user thread) and avoiding risk of blocking entire process when one of the thread calls system blocking. Even so it has its own disadvantages including having obliged to create a kernel thread for each user thread which can be costly. Also having too many kernel threads can affect the performance of the application because one kernel thread can run on only one processor. So if you're having multiprocessor system, let's say 4 cores, then creating more than 4 kernel thread causes overhead and burden to the application. Because of this usually applications set limits on how many threads can be created.
Many to many model: Many user threads multiplexes to equal or less kernel threads.
Definition of multiplex: system or signal involving simultaneous transmission of several messages along a single channel of communication.
The number of kernel may be specified depending on the machine or the application. Developer can create user level threads as many as they want. Even after user thread calls blocking system, the entire process won't blocked. Basically it's the most ideal model among all three.
Hyperthreading or Simultaneous Multithreading: It's basically whether your system has logical processors. Logical processor is the doubled version of your physical processor (cores). If I have 4 physical processor then I might have 8 logical processor, so my machine can process 8 threads concurrently. To see whether your system supports logical processors (windows) go to cmd and type wmic then type CPU Get NumberOfCores, NumberOfLogicalProcessors. If two numbers are the same then your system doesn't support hyperthreading.
king
dai muusco
AI generated text ahh comment
Thank you
/* Omg, this is the first time when I applied my theoretically knowledge of operating system in my Life */
Lol ppl r gonna overlook this joke
@@pmllncktwhat joke
@@TragicGFuel it's a comment:)
In some systems (especially real-time systems), an asynchronous connection exists between user and kernel threads. That is, a user thread can make a request to a kernel thread, and that request is queued to the kernel thread. The user thread can then continue processing while the kernel thread does its processing (in parallel on a multi-core system). When the kernel finishes, it sends the results to the user thread (either with a callback function of queuing the results to the user thread).
This type of user/kernel connection allows a one-to-many relationship. The user thread can be connected to many kernel threads. This relationship also can change the many-to-many relationship. A user thread can connect to many kernel cores, while a kernel thread can connect to many user threads. This is the most powerful of models but also the most difficult to implement.
With this many-to-many model, a user thread does not block when a kernel thread does. Each user thread can do more work, increasing the amount of processing a multicore system can do. In addition, each kernel thread can be specialized, making each kernel thread simpler and smaller. Programming to take advantage of these capabilities is more difficult than in the other models.
Let me give an example - crypto-mining. The engineer creates many user threads to perform the crypto-mining calculations. One kernel thread delivers the next piece to user threads while another kernel thread receives and records the results. The user thread requests the next piece and waits until it shows up. When it gets that piece, it requests the next (or even several pieces) and then starts processing the piece it has. When it completes, it sends the results to the record thread, gets the next piece off of its queue, and starts processing again. In this example, user threads will process data almost 100% of the time. Kernel threads do not stall user threads, and user threads do not stall kernel threads. However, user and kernel threads must implement these inter-process queues (a non-trivial exercise).
Thanks for adding this to my knowledge. This comment should be pinned.
best yt channel for preparing subjects and getting concepts cleared
I have no words to appreciate you Sir, such a best way of teaching.🥰
thanks a bunch, guy! you're providing quality unmatched education, here on yt for free. GOD bless:) ❤❤
It's so cool to see what is going inside.
What an amazing explanation man....... Great piece of work
Tq sir.... For more information rather than our syllabus... ☺☺☺
No words to explain this is the Best
In Linux world, the word "kernel thread" is used to refer to threads running in kernel space, like ksoftirqd, kworker, kswapd etc. which can be shown when you type "ps aux" in the terminal.
In this video, "kernel thread" is used as threads managed as "struct task_struct" in the linux source code.
User threads on the other hand are like pseudo-threads implemented in userspace, where each user threads are assigned memory area for its stack and CPU resisters saved on pseudo-context-switch, triggered by userspace libraries like tokio (popular asynchronous runtime in Rust).
Hyperthreading is a totally different concept, where the CPU shows the OS an illusion that it has more threads than its cores (of course OS can be informed whether hyperthreading is activated or not).
Neso Academy is sruely the best
Really helpful for concept clarity
Solid Explanation 👍⚙️🔗📝
Beautifully Explained.
The video is amazing, yet...there is still the open question, how the HyperThreading really works, and is it really a performance-increase along with the the question: how do the L1 and L2 -caches get utilized by the logical-threads then?
Thankyou for the video But there is a correction:
Although many-to-many model posses no disadvantages of the other models, in practice it is difficult to implement. Also because modern systems has increasing number of cores (and features like hyper-threading), the kernel thread limitation can be removed. Because of these reasons, most OSs are using the *One-to-One* model instead.
Thank you! Very clearly explained
Simply marvalous explanation
Thank you sir... Your videos are really helpfull.It helps me to understand to topics of book...
So beautiful so elegant class
1) Multi-threading
- 2 types of threads: user thread and kernel thread
- User thread run on top of the OS and is not support by the OS
- Kernel thread is support by the OS
- A relationship must exist between these 2 threads, called multithreading
- 3 types of relationships: many to one, one to one and many to many
- Many to one: multiple user threads are linked to only one kernel thread. When an user thread make a blocking system call, it will block the other threads or the whole process.
- One to one: one user thread is linked to one kernel thread. This model can solve the many to one problem, but the number of kernel threads is limited, so it limits the user threads created.
- Many to many: multiple user thread are linked to an equal or less than number of kernel threads. So when an user thread makes a blocking system call, the other user threads will be scheduled to another kernel thread
2) Hyperthreading or Simultaneous Multithreading (SMT)
- Hyperthreaded systems allows their processor core to become multiple logically processors
Thank you for this.
Best explanation.
I will get subscription of your neso app but there are nothing facility to discuss with faculty so please help me sir i have one question
can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on single processor system
Plzz sir explain me in detail
Hi Nesoacademy... When your channel was hacked and we shifted to a new channel then i too put many tweets to bring back your channel..We were lucky that we got back on that time...
I want to say that if you will be providing notes then it will be good for us to keep track...and revise things easily...
it's a huge request to provide these notes of the videos.
thank you
Hello Abhishek, thank you for your support when we needed it. Our team is working on the notes and soon they will be available on our website + app. You can also use the ppts to revise the lectures, please follow the link www.nesoacademy.org/cs/03-operating-system/ppts
@@nesoacademy TYSM sir.
This is the simplicity and great honour of Nesoacademy .
We will be waiting.
Thanks again
Great series keep it up
thank you very much sir for this video
Love your videos.
clearly explained!!!! Thank you
very clearly explained
you are the man Love your videos
great explanation.
thank man your video very easy to understand
Bro this is not fair because I was searching for videos like this for my exam but not found , but u uploaded it today but I have completed my exam just 1 day back from the date u have uploaded .
So sad 😞😞😞😞
What does threads do in computers
@@mwatelaswalehe1506 Thread is created by a process,each time will you open a application it creates a thread for that specific application Which handles the task related to that particular application.
An alternate way to know number of cores and number of logical processors is to open Task Manager in Windows and navigate to performance tab.
If you want to check if your Windows machine has hyper-threading capability, you can search for system information in the search bar. In the system summary, you can see how many cores and also how many logical processors your machine has
What does a thread pool do? What is it's function or purpose?
Amazing sir
excellent video thank you so much
just you are special one!
Why many-to-one is blocked but many-to-many does not ? I can not understand this part
Bcoz there is one K..
Helpful 👍👍
Bst very nice
amazing
thank you
By Kernel threads do you mean hardware threads? So in an one to one user thread to kernel thread mapping it basically means in a system like that no software multithreading would be possible unless it has multiple cores/hyperthreading is enabled?
user level thread and kernel level thread what is use why user level thread depend on kernel level thread as you showed in diagram
what is the equivalent command of WMIC in Macbook?
So, according to my understanding
1 processor, 2 cores (single processor) = can run 2 thread
2 processor, each one core (multiprocessor) = can run 2 thread
is my understanding correct? Pls answer this
Gil in python. (Many to one)
thankyou very much
sir i have learned that each processor has one core and a core have 1 or 2 threads depending whether it is a hyper threading or not BUT for a process they have many segment of threads to get executed.please clarify my doubt.
i can see (2 cores and 4 logical processes it means 4 threads BESIDE that i can see 200 process and 2k threads)in task manager. please clarify my doubt .
@@gopikrishna1551 I think even though there are 2k threads showing in Your task Manager ...there can be maximum of 4 active threads running since You have 4 logical cores and remaining threads are inactive . This is what I think . Correct Me If Iam Wrong .
How many threads we can run in single core processor ?
One thread if hyper two
Awesome thank u so much
Thankyou sir
Hyperthreading in cmd shows error what should i do how to get number of cores of logical processors
Cool. You should have made a separate video for hyper-threading
Thank you soo much!
ne okuyosun özlem :)
@@huseyincoban1214 bilgisayar mühendisliği
@@NoOneIsHereRightNow ben de bilgisayar mühendisliği okuyorumm, nerede okuyorsun ?
@@huseyincoban1214 İstanbul
@@NoOneIsHereRightNow ya ne güzel ,bende muğladayımm :) peki kaçıncı senen orada?
use lscpu command for linux based OS
hey,,i have some kinda complaint about this operatiig system playlist
in all other chapters videos are not soo lengthy as this chapter,
ths operating system chapter makes mad
what is core ?
when i typed wmic:root\cli>CPU Get NumberOfCores.NumberOfLogicallProcessors ,it shows error...can anyone help
just use task manager to find out if you have hyperthreading ALT+CTRL+DELETE
You have to click on:
ALT+CTRL+DEL
then, it shows an some options,then go with task manager and maximize the screen which is newly opened and click on PERFORMANCE button which in top bar then u will see CPU curve below the CPU curve u will finally find that CORES: ---
LOGICAL PROCESSORS: ---
-Thank you
you should put comma instead of full stop between number of cores and number of logical processors
physical core = 4, logical core = 8.
it is surprising, i have 10 cores and 12 logical processors . there should be 20 logical processors. isn't it?
confused between core and thread !
How do I follow you on Instagram?
here for the update
👍👍
Why are user threads and kernel threads relationship needed?
Cpu only executes kernel threads. So mapping Between user threads and Kernel threads needs to execute user threads.
The mapping between user threads and kernel threads is necessary because the CPU only executes kernel threads directly. User threads, which operate in user space, need to be mapped to kernel threads to:
Enable the execution of user-space code.
Provide multitasking, concurrency, and parallelism.
Allow efficient context switching and management of blocking system calls.
Sir I think your name is JAISON...
I'm a super super beginner. Ssb
how to put auto-generated subtitles in this video ?
just press C
🥹🫶🏻
windows xp lol
no god but Allah
What is block g system @nesoacedemy
I will get subscription of your neso app but there are nothing facility to discuss with faculty so please help me sir i have one question
can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on single processor system
Plzz sir explain me in detail