Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have a question the that i could not find an answer anywhere:
1) where does the kernel main loop execute on smp machine - i mean NOT the kernel threads or system calls.
2) how many instances of the scheduler are executing? is there an instance on every CPU once timer interrupt has expired?
Your attempt to bump this thread has had just the opposite result by removing it from the "Zero Reply Threads" list. Threads on that list get some automatic bumps and would also be seen by those who check that zero-reply list periodically.
i have a question the that i could not find an answer anywhere:
1) where does the kernel main loop execute on smp machine - i mean NOT the kernel threads or system calls.
Both
Quote:
2) how many instances of the scheduler are executing? is there an instance on every CPU once timer interrupt has expired?
Depends on your definition of "instance". One per processor (when idle). Normally though, all processors will go idle when there is nothing to do (and there is one idle process for each CPU). There will only be one processor examining the run queue at a time (atomic operators), so scheduling is handled appropriately with all other processors waiting.
NOTE: This does not mean there is duplicate code - just that two (or more) processors will execute the same loop. What happens is that the "loop" gets copied into local cache, and the CPU runs it out of cache.
in an smp system, the kernel code is shared in memory by all the processors. So only one cpu executes the kernel code in a
given instant of time. (This is an example of the big kernel lock). So accordingly, the only one cpu executes the scheduler code.
Now each cpu may have its own set of run queues of tasks. This the kernel identifies which cpu owns which queue by the CPUID instruction
supported by the hardware.
in an smp system, the kernel code is shared in memory by all the processors. So only one cpu executes the kernel code in a
given instant of time. (This is an example of the big kernel lock). So accordingly, the only one cpu executes the scheduler code.
Now each cpu may have its own set of run queues of tasks. This the kernel identifies which cpu owns which queue by the CPUID instruction
supported by the hardware.
Hope this helps.
That was true in version 2.2, but by the time 2.6 has rolled out the big kernel lock has been removed.
Many parts of the kernel are executed in parallel. Device drivers, kernel tasks, interrupt service... even process scheduling.
There is no "big kernel lock" anymore, instead there is a lot of small locks on specific data structures. The scheduler has such a lock - the only lock is taken while removing a process from the queue and dispatching to a processor.
There are also multiple run queues - one per processor to avoid/reduce locking overhead.
Thanks for your reply
But still- where for example does the pgae cache execute or vfs
Or for clarity: where do fundamental kernel tasks are executed?
I mean tasks which are not related to any user( not systems calls) and is there one main loop in the kernel?
Thanks again
All processors execute it when there is nothing else to do.
In an SMP, all processors execute everything as needed. Those sections that require serial access will be protected by either queues (a processor enters the task into a list, then goes to do something else while another processor executes tasks on the list, when the list is empty it goes to do something else) or locks (a processor waits until it acquires the lock, then performs the action and releases the lock). Interrupts are taken by an idle processor. If all processors a busy, one is interrupted (as long as it isn't already in a non-interruptible section).
Anything much more detailed than that would require a book/chapter on kernel design.
jpollard- what do you mean "In an SMP, all processors execute everything as needed" - what in the kernel is responsible for assigning tasks (not system calls) to processors? (i mean the routine tasks)
The scheduler. Every processor executes the scheduler as part of the idle task. If anything is in a queue then the processor will switch to that task. When the task is completed it goes back to the idle/scheduler for the next task.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.