views:

101

answers:

2

Hi:

For a multi-core computer running Linux 2.6.x, what happens when a thread makes a system call? Does it drop into the kernel only on the core that the thread is running on, or does it drop into the kernel on all cores (sorry if this is a newbie question).

Is this behaviour (whichever is the correct one) the same when receiving interrupts in general? If not, what are the differences?

+4  A: 

Only the thread that does the syscall enters the kernel. All scheduling in Linux is done on thread granularity. As for interrupts - they are routed to one core, i.e. only one processor is interrupted for each given hardware event. Then interrupts could be manually assigned to specific cores. This is done with a mask in /proc/irq/IRQ-NUMBER/smp_affinity. You can see which CPUs receive what hardware interrupts in /proc/interrupts.

Nikolai N Fetissov
A: 

Ony one core handles a system call, and only one core handles an interrupt.

I don't have any references off hand for exactly how interrupts are routed - perhaps Intel's System Programming Guide would be helpful here.

But, imagine if all cores were interrupted by every system call or interrupt. Linux is designed to scale to many cores. This would kill that scalability - on a massive server every disk I/O, timer interrupt, etc., would effectively stall every single core in the system, preventing them from doing useful work.

Michael