LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-11-2013, 10:02 PM   #1
anup.estuff
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Rep: Reputation: Disabled
Linux kernel Scheduling in Multicore


I have some doubts regarding some linux kernel scheduling.

1) Does linux kernel(schedular to be specific) always runs on CPU-0?
2) One Scenario:
One kernel thread running on CPU - 0, goes into sleep with interrupts disabled.
In this case, will the schedular run on other CPU?
if Yes, how is the selection made out of the remaining core so as to which will run
the schedular, is this decision made while disabling interrupts on CPU - 0?
 
Old 10-12-2013, 07:34 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
"1) Does linux kernel(schedular to be specific) always runs on CPU-0?"

No

"One kernel thread running on CPU - 0, goes into sleep with interrupts disabled.
In this case, will the schedular run on other CPU?"

A kernel thread going into sleep does not stop any CPU. It just stops the thread. The scheduler can run on any CPU at any time.

"how is the selection made out of the remaining core so as to which will run
the schedular"

The scheduler runs on the same CPU as the kernel routine that called the scheduler.

---------------------
Steve Stites
 
Old 10-12-2013, 09:24 PM   #3
anup.estuff
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jailbait View Post
"1) Does linux kernel(schedular to be specific) always runs on CPU-0?"

No

"One kernel thread running on CPU - 0, goes into sleep with interrupts disabled.
In this case, will the schedular run on other CPU?"

A kernel thread going into sleep does not stop any CPU. It just stops the thread. The scheduler can run on any CPU at any time.

"how is the selection made out of the remaining core so as to which will run
the schedular"

The scheduler runs on the same CPU as the kernel routine that called the scheduler.

---------------------
Steve Stites
Thanks for taking your time for replying, I appreciate.
I have one more doubt.
When interrupts are disabled on one CPU, and suppose all the other CPU's receive timer interrupt exactly at the same time,
on which CPU will the schedular run? ( as per my current knowledge timer interrupt interrupt is one of the way the schedular gets invoked)
Is there any selection algorithm OR a voting mechanism to decide as to who will run the schedular?( or is it the case that schedular runs on each of the cores? ) .
 
Old 10-13-2013, 12:08 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
"When interrupts are disabled on one CPU, and suppose all the other CPU's receive timer interrupt exactly at the same time,
on which CPU will the schedular run? "

Interrupts being disabled on one CPU is irrelevant to the question. Timer interrupts are generated by the hardware. So if multiple CPUs generate simultaneous timer interrupts then the scheduler will be running simultaneously as threads on multiple CPUs. Whenever one of the CPUs reach the point where single threading is necessary because the scheduler is manipulating system control blocks then that instance of the scheduler will issue interrupts to the other CPUs stopping the other CPUs. When multi-threading is again permissible then that scheduler thread will start all of the CPUs that it stopped. The order that the CPUs run through the single threading code is determined by the order in which they issue the stop to the other CPUs. I don't know how the hardware decides which CPU(s) to stop when two or more CPUs happen to issue the stop interrupt simultaneously.

-------------------------
Steve Stites
 
Old 10-14-2013, 09:44 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
IIRC, that statement about "stopping the other CPUs" is not quite accurate. What actually would happen is this:
  • The interrupt may be received by more than one CPU at a time.
  • Therefore, multiple CPUs may enter the scheduler at more or less the same time.
  • Spinlocks are used wherever any of the CPUs may be manipulating a particular shared data-structure, so that only one of the CPUs (it's unpredictable which one ...) will proceed.
Each CPU or core makes its own scheduling decisions. The scheduler is designed so that they may do so fairly.
 
  


Reply

Tags
kernel 3, linux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread scheduling on multicore hemalbavisi Linux - Kernel 2 07-08-2013 03:58 AM
need help on linux kernel scheduling from you sachinchhatna Linux - Kernel 1 09-08-2012 07:46 PM
need help on linux kernel scheduling from you sachinchhatna Linux - Newbie 3 09-07-2012 01:35 AM
need help on linux kernel scheduling sachinchhatna Linux - Kernel 1 08-16-2012 08:54 AM
[SOLVED] is there multicore scheduling support for ARM architecture coolsandyforyou Linux - Software 1 12-08-2010 02:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration