where does kernel execute on smp
hi
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? thanks in advance |
Up
:-D |
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.
|
Quote:
Quote:
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. Quote:
|
Hi
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. |
Quote:
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. http://www.ibm.com/developerworks/library/l-scheduler/ |
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 |
The only "main loop" is the idle task.
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)
thanks |
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.
|
All times are GMT -5. The time now is 04:27 AM. |