I have a doubt.
There are 10 different threads in runnable state. Each having priority 1 to 10. How does the CPU schedules or executes these threads?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The OS has a thread scheduler that will (using an algorithm) decide based on priority and a few other factors, which thread will be run next. If you have a multi-core system, then each CPU can take a thread for it’s account.
There’s also the fact that a thread gets a slot of time, and then gets switched out for another thread and has to wait its turn again.
But thread scheduling is an Operating System function.
I hope that gives you an answer to your question.